From 9d80d07f09e90146b0f9e64a48848ebc86e1b4c8 Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 24 May 2022 21:08:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/main/MainActivity.kt | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) 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())