mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-12-22 20:40: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.NFC.Comms
|
||||||
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentAuthBinding
|
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentAuthBinding
|
||||||
import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel
|
import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel
|
||||||
|
import java.lang.Exception
|
||||||
import kotlin.concurrent.thread
|
import kotlin.concurrent.thread
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,14 +44,19 @@ class AuthFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
timer = object : CountDownTimer(90000, 1000) {
|
timer = object : CountDownTimer((timeRemaining * 1000).toLong(), 1000) {
|
||||||
override fun onTick(p0: Long) {
|
override fun onTick(p0: Long) {
|
||||||
binding!!.timeCounter.text = getString(R.string.time_left, timeRemaining)
|
|
||||||
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() {
|
override fun onFinish() {
|
||||||
binding!!.timeCounter.text = getString(R.string.no_time)
|
Thread.sleep(750)
|
||||||
|
goToTheStart()
|
||||||
}
|
}
|
||||||
}.start()
|
}.start()
|
||||||
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
||||||
@ -69,6 +75,7 @@ class AuthFragment : Fragment() {
|
|||||||
val card = IsoDep.get(tag)
|
val card = IsoDep.get(tag)
|
||||||
card.timeout = 32768
|
card.timeout = 32768
|
||||||
card.use {
|
card.use {
|
||||||
|
try {
|
||||||
val comms = Comms(it, viewModel.userCan)
|
val comms = Comms(it, viewModel.userCan)
|
||||||
val response = comms.readPersonalData(byteArrayOf(1, 2, 6))
|
val response = comms.readPersonalData(byteArrayOf(1, 2, 6))
|
||||||
if (response != null) {
|
if (response != null) {
|
||||||
@ -79,9 +86,18 @@ class AuthFragment : Fragment() {
|
|||||||
binding!!.timeCounter.text = getString(R.string.data_read)
|
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()
|
it.close()
|
||||||
adapter.disableReaderMode(activity)
|
adapter.disableReaderMode(activity)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, NfcAdapter.FLAG_READER_NFC_A, null)
|
}, NfcAdapter.FLAG_READER_NFC_A, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,9 @@ class PinFragment : Fragment() {
|
|||||||
|
|
||||||
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
binding!!.nextButton.setOnClickListener { goToNextFragment() }
|
||||||
binding!!.cancelButton.setOnClickListener { goToTheStart() }
|
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() {
|
private fun goToNextFragment() {
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<string name="pin_fragment">Palun sisesta PIN 1</string>
|
<string name="pin_fragment">Palun sisesta PIN 1</string>
|
||||||
<string name="enter_pin">PIN 1</string>
|
<string name="enter_pin">PIN 1</string>
|
||||||
<string name="example_pin">Näide. 1234</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 resources for CanFragment -->
|
||||||
<string name="example_can">Näide. 123456</string>
|
<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="enter_can">Sisesta ID kaardi CAN (Card Access Number)</string>
|
||||||
<string name="length_can">CANi pikkus on vale</string>
|
<string name="length_can">CANi pikkus on vale</string>
|
||||||
<string name="card_detected">Kaart on tuvastatud. Hoia kaarti vastu telefoni.</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 resources for AuthFragment layout -->
|
||||||
<string name="auth_instruction_text">ID kaardiga ühenduse loomiseks pane kaart vastu telefoni</string>
|
<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="time_left">Aega on jäänud %d sek</string>
|
||||||
<string name="no_time">Aeg on otsas</string>
|
<string name="no_time">Aeg on otsas</string>
|
||||||
|
<string name="no_success">Vale CAN</string>
|
||||||
|
|
||||||
<!-- string resources for UserFragment layout -->
|
<!-- string resources for UserFragment layout -->
|
||||||
<string name="user_name_label">NIMI</string>
|
<string name="user_name_label">NIMI</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user