pull/49/head
kunfei 5 years ago
parent 2bafc67895
commit fb66f6538f
  1. 34
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt

@ -17,7 +17,6 @@ import io.legado.app.help.ActivityHelp
import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.Permissions
import io.legado.app.help.permission.PermissionsCompat import io.legado.app.help.permission.PermissionsCompat
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
import io.legado.app.help.storage.Restore
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.dialogs.noButton import io.legado.app.lib.dialogs.noButton
import io.legado.app.lib.dialogs.yesButton import io.legado.app.lib.dialogs.yesButton
@ -63,25 +62,20 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
} }
private fun restore() { private fun restore() {
if (getPrefBoolean("dbChange")) { launch {
Restore.restore() if (withContext(IO) { App.db.bookDao().allBookCount == 0 }) {
putPrefBoolean("dbChange", false) alert(title = "导入") {
} else if (getPrefInt("versionCode") == 0) { message = "是否导入旧版本数据"
launch { yesButton {
if (withContext(IO) { App.db.bookDao().allBookCount == 0 }) { PermissionsCompat.Builder(this@MainActivity)
alert(title = "导入") { .addPermissions(*Permissions.Group.STORAGE)
message = "是否导入旧版本数据" .rationale(R.string.tip_perm_request_storage)
yesButton { .onGranted { viewModel.importYueDuData() }
PermissionsCompat.Builder(this@MainActivity) .request()
.addPermissions(*Permissions.Group.STORAGE) }
.rationale(R.string.tip_perm_request_storage) noButton {
.onGranted { viewModel.importYueDuData() } }
.request() }.show().applyTint()
}
noButton {
}
}.show().applyTint()
}
} }
} }
} }

Loading…
Cancel
Save