mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-12-22 04:20:16 +02:00
MOB-14 improved the user experience
This commit is contained in:
parent
fc56825ed0
commit
cc35723c07
@ -15,6 +15,7 @@ import androidx.navigation.fragment.findNavController
|
||||
import com.tarkvaraprojekt.mobileauthapp.NFC.Comms
|
||||
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentAuthBinding
|
||||
import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel
|
||||
import java.lang.Exception
|
||||
import kotlin.concurrent.thread
|
||||
|
||||
/**
|
||||
@ -43,14 +44,19 @@ class AuthFragment : Fragment() {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
timer = object : CountDownTimer(90000, 1000) {
|
||||
timer = object : CountDownTimer((timeRemaining * 1000).toLong(), 1000) {
|
||||
override fun onTick(p0: Long) {
|
||||
binding!!.timeCounter.text = getString(R.string.time_left, timeRemaining)
|
||||
timeRemaining--
|
||||
if (timeRemaining == 0) {
|
||||
binding!!.timeCounter.text = getString(R.string.no_time)
|
||||
} else {
|
||||
binding!!.timeCounter.text = getString(R.string.time_left, timeRemaining)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFinish() {
|
||||
binding!!.timeCounter.text = getString(R.string.no_time)
|
||||
Thread.sleep(750)
|
||||
goToTheStart()
|
||||
}
|
||||
}.start()
|
||||
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
||||
@ -69,18 +75,28 @@ class AuthFragment : Fragment() {
|
||||
val card = IsoDep.get(tag)
|
||||
card.timeout = 32768
|
||||
card.use {
|
||||
val comms = Comms(it, viewModel.userCan)
|
||||
val response = comms.readPersonalData(byteArrayOf(1, 2, 6))
|
||||
if (response != null) {
|
||||
viewModel.setUserFirstName(response[1])
|
||||
viewModel.setUserLastName(response[0])
|
||||
viewModel.setUserIdentificationNumber(response[2])
|
||||
requireActivity().runOnUiThread{
|
||||
binding!!.timeCounter.text = getString(R.string.data_read)
|
||||
try {
|
||||
val comms = Comms(it, viewModel.userCan)
|
||||
val response = comms.readPersonalData(byteArrayOf(1, 2, 6))
|
||||
if (response != null) {
|
||||
viewModel.setUserFirstName(response[1])
|
||||
viewModel.setUserLastName(response[0])
|
||||
viewModel.setUserIdentificationNumber(response[2])
|
||||
requireActivity().runOnUiThread{
|
||||
binding!!.timeCounter.text = getString(R.string.data_read)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
requireActivity().runOnUiThread {
|
||||
binding!!.timeCounter.text = getString(R.string.no_success)
|
||||
}
|
||||
// Gives user some time to read the error message
|
||||
Thread.sleep(1000)
|
||||
goToTheStart()
|
||||
} finally {
|
||||
it.close()
|
||||
adapter.disableReaderMode(activity)
|
||||
}
|
||||
it.close()
|
||||
adapter.disableReaderMode(activity)
|
||||
}
|
||||
}, NfcAdapter.FLAG_READER_NFC_A, null)
|
||||
}
|
||||
|
@ -34,6 +34,9 @@ class PinFragment : Fragment() {
|
||||
|
||||
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
||||
binding!!.cancelButton.setOnClickListener { goToTheStart() }
|
||||
// Currently PIN 1 is not required and thus this step is immediately skipped.
|
||||
// In the future the UI flow will be changed in the nav_graph.
|
||||
goToNextFragment()
|
||||
}
|
||||
|
||||
private fun goToNextFragment() {
|
||||
|
@ -7,10 +7,10 @@
|
||||
<string name="cancel_text">KATKESTA</string>
|
||||
|
||||
<!-- string resources for PinFragment -->
|
||||
<string name="pin_fragment">Palun sisesta PIN1</string>
|
||||
<string name="enter_pin">PIN1</string>
|
||||
<string name="pin_fragment">Palun sisesta PIN 1</string>
|
||||
<string name="enter_pin">PIN 1</string>
|
||||
<string name="example_pin">Näide. 1234</string>
|
||||
<string name="length_pin">PIN1 lubatud pikkus on 4-12</string>
|
||||
<string name="length_pin">PIN 1 lubatud pikkus on 4..12</string>
|
||||
|
||||
<!-- string resources for CanFragment -->
|
||||
<string name="example_can">Näide. 123456</string>
|
||||
@ -18,12 +18,13 @@
|
||||
<string name="enter_can">Sisesta ID kaardi CAN (Card Access Number)</string>
|
||||
<string name="length_can">CANi pikkus on vale</string>
|
||||
<string name="card_detected">Kaart on tuvastatud. Hoia kaarti vastu telefoni.</string>
|
||||
<string name="data_read">Andmed loetud.</string>
|
||||
<string name="data_read">Andmed loetud. Võid edasi minna.</string>
|
||||
|
||||
<!-- string resources for AuthFragment layout -->
|
||||
<string name="auth_instruction_text">ID kaardiga ühenduse loomiseks pane kaart vastu telefoni</string>
|
||||
<string name="time_left">Aega on jäänud %d sek</string>
|
||||
<string name="no_time">Aeg on otsas</string>
|
||||
<string name="no_success">Vale CAN</string>
|
||||
|
||||
<!-- string resources for UserFragment layout -->
|
||||
<string name="user_name_label">NIMI</string>
|
||||
|
Loading…
Reference in New Issue
Block a user