diff --git a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt index 21d6be4af..ee7d85737 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainActivity.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainActivity.kt @@ -96,19 +96,7 @@ class MainActivity : VMBaseActivity(), binding.viewPagerMain.postDelayed(3000) { viewModel.postLoad() } - launch { - val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() } - ?: return@launch - if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) { - LocalConfig.lastBackup = lastBackupFile.lastModify - alert("恢复", "webDav书源比本地新,是否恢复") { - cancelButton() - okButton { - viewModel.restoreWebDav(lastBackupFile.displayName) - } - } - } - } + syncAlert() } override fun onNavigationItemSelected(item: MenuItem): Boolean = binding.run { @@ -158,6 +146,26 @@ class MainActivity : VMBaseActivity(), } } + /** + * 同步提示 + */ + private fun syncAlert() = launch { + val lastBackupFile = withContext(IO) { AppWebDav.lastBackUp().getOrNull() } + ?: return@launch + if (lastBackupFile.lastModify - LocalConfig.lastBackup > DateUtils.MINUTE_IN_MILLIS) { + LocalConfig.lastBackup = lastBackupFile.lastModify + alert("恢复", "webDav书源比本地新,是否恢复") { + cancelButton() + okButton { + viewModel.restoreWebDav(lastBackupFile.displayName) + } + } + } + } + + /** + * 用户隐私与协议 + */ private fun privacyPolicy() { if (LocalConfig.privacyPolicyOk) return val privacyPolicy = String(assets.open("privacyPolicy.md").readBytes())