Skip to content
Snippets Groups Projects

Show a warning for wrong system time during startup

Merged Torsten Grote requested to merge 138-clock-skew-warning into main
2 unresolved threads
10 files
+ 190
13
Compare changes
  • Side-by-side
  • Inline
Files
10
/*
* Briar Mailbox
* Copyright (C) 2021-2022 The Briar Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
package org.briarproject.mailbox.android.ui
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.collect
import org.briarproject.mailbox.R
import org.briarproject.mailbox.android.StatusManager.ErrorClockSkew
import org.briarproject.mailbox.android.StatusManager.MailboxAppState
import org.briarproject.mailbox.android.ui.ClockSkewFragmentDirections.actionClockSkewFragmentToStartupFragment
@AndroidEntryPoint
class ClockSkewFragment : Fragment() {
private val viewModel: MailboxViewModel by activityViewModels()
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?,
): View? {
return inflater.inflate(R.layout.fragment_clock_skew, container, false)
}
override fun onViewCreated(v: View, savedInstanceState: Bundle?) {
launchAndRepeatWhileStarted {
viewModel.appState.collect { onSetupStateChanged(it) }
}
}
private fun onSetupStateChanged(state: MailboxAppState) {
if (state != ErrorClockSkew) {
findNavController().navigate(actionClockSkewFragmentToStartupFragment())
}
}
}
Loading