mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-11-04 21:11:00 +02:00
made some changes related to the demo next week
This commit is contained in:
parent
bd686739fc
commit
3e5f02f842
@ -78,10 +78,13 @@ class AuthFragment : Fragment() {
|
|||||||
card.use {
|
card.use {
|
||||||
try {
|
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, 3, 4, 8))
|
||||||
viewModel.setUserFirstName(response[1])
|
viewModel.setUserFirstName(response[1])
|
||||||
viewModel.setUserLastName(response[0])
|
viewModel.setUserLastName(response[0])
|
||||||
viewModel.setUserIdentificationNumber(response[2])
|
viewModel.setUserIdentificationNumber(response[2])
|
||||||
|
viewModel.setGender(response[3])
|
||||||
|
viewModel.setCitizenship(response[4])
|
||||||
|
viewModel.setExpiration(response[5])
|
||||||
requireActivity().runOnUiThread{
|
requireActivity().runOnUiThread{
|
||||||
binding!!.timeCounter.text = getString(R.string.data_read)
|
binding!!.timeCounter.text = getString(R.string.data_read)
|
||||||
}
|
}
|
||||||
@ -89,6 +92,8 @@ class AuthFragment : Fragment() {
|
|||||||
requireActivity().runOnUiThread {
|
requireActivity().runOnUiThread {
|
||||||
binding!!.timeCounter.text = getString(R.string.no_success)
|
binding!!.timeCounter.text = getString(R.string.no_success)
|
||||||
}
|
}
|
||||||
|
// If the CAN is wrong we will also delete the saved CAN so that the user won't use it again.
|
||||||
|
viewModel.deleteCan(requireContext())
|
||||||
// Gives user some time to read the error message
|
// Gives user some time to read the error message
|
||||||
Thread.sleep(1000)
|
Thread.sleep(1000)
|
||||||
goToTheStart()
|
goToTheStart()
|
||||||
|
@ -33,13 +33,25 @@ class UserFragment : Fragment() {
|
|||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
displayInformation()
|
||||||
binding!!.userName.text =
|
|
||||||
getString(R.string.user_name, viewModel.userFirstName, viewModel.userLastName)
|
|
||||||
binding!!.identificationNumber.text = viewModel.userIdentificationNumber
|
|
||||||
binding!!.clearButton.setOnClickListener { goToTheStart() }
|
binding!!.clearButton.setOnClickListener { goToTheStart() }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Assigns text values to the fields in order to display user information.
|
||||||
|
*/
|
||||||
|
private fun displayInformation() {
|
||||||
|
binding!!.userName.text =
|
||||||
|
getString(R.string.user_name, viewModel.userFirstName, viewModel.userLastName)
|
||||||
|
binding!!.identificationNumber.text = viewModel.userIdentificationNumber
|
||||||
|
binding!!.gender.text = viewModel.gender
|
||||||
|
binding!!.expiration.text = viewModel.expiration.replace(" ", "/")
|
||||||
|
binding!!.citizenship.text = viewModel.citizenship
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Navigates user back to the start and also deletes any temporary information.
|
||||||
|
*/
|
||||||
private fun goToTheStart() {
|
private fun goToTheStart() {
|
||||||
viewModel.clearUserInfo()
|
viewModel.clearUserInfo()
|
||||||
findNavController().navigate(R.id.action_userFragment_to_homeFragment)
|
findNavController().navigate(R.id.action_userFragment_to_homeFragment)
|
||||||
|
@ -23,12 +23,24 @@ class SmartCardViewModel: ViewModel() {
|
|||||||
private var _userIdentificationNumber: String = ""
|
private var _userIdentificationNumber: String = ""
|
||||||
val userIdentificationNumber get() = _userIdentificationNumber
|
val userIdentificationNumber get() = _userIdentificationNumber
|
||||||
|
|
||||||
|
private var _gender: String = ""
|
||||||
|
val gender get() = _gender
|
||||||
|
|
||||||
|
private var _expiration: String = ""
|
||||||
|
val expiration get() = _expiration
|
||||||
|
|
||||||
|
private var _citizenship: String = ""
|
||||||
|
val citizenship get() = _citizenship
|
||||||
|
|
||||||
fun clearUserInfo() {
|
fun clearUserInfo() {
|
||||||
_userPin = ""
|
_userPin = ""
|
||||||
_userCan = ""
|
_userCan = ""
|
||||||
_userFirstName = ""
|
_userFirstName = ""
|
||||||
_userLastName = ""
|
_userLastName = ""
|
||||||
_userIdentificationNumber = ""
|
_userIdentificationNumber = ""
|
||||||
|
_expiration = ""
|
||||||
|
_citizenship = ""
|
||||||
|
_gender = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setUserPin(newUserPin: String) {
|
fun setUserPin(newUserPin: String) {
|
||||||
@ -51,6 +63,18 @@ class SmartCardViewModel: ViewModel() {
|
|||||||
_userIdentificationNumber = newUserIdentificationNumber
|
_userIdentificationNumber = newUserIdentificationNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setExpiration(newExpiration: String) {
|
||||||
|
_expiration = newExpiration
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setCitizenship(newCitizenship: String) {
|
||||||
|
_citizenship = newCitizenship
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setGender(newGender: String) {
|
||||||
|
_gender = newGender
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getSharedPreferences(context: Context): SharedPreferences {
|
private fun getSharedPreferences(context: Context): SharedPreferences {
|
||||||
val masterKeyAlias: String = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
val masterKeyAlias: String = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/next_text"
|
android:text="@string/next_text"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
@ -73,7 +73,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/cancel_text"
|
android:text="@string/cancel_text"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/next_button"
|
app:layout_constraintEnd_toStartOf="@id/next_button"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/next_text"
|
android:text="@string/next_text"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
@ -77,7 +77,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/cancel_text"
|
android:text="@string/cancel_text"
|
||||||
android:textSize="18dp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/next_button"
|
app:layout_constraintEnd_toStartOf="@id/next_button"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/begin_text"
|
android:text="@string/begin_text"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/saved_states"
|
app:layout_constraintTop_toBottomOf="@id/saved_states"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"/>
|
app:layout_constraintEnd_toEndOf="parent"/>
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/next_text"
|
android:text="@string/next_text"
|
||||||
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
app:layout_constraintStart_toEndOf="@id/cancel_button"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
@ -75,6 +76,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="24dp"
|
android:layout_marginTop="24dp"
|
||||||
android:text="@string/cancel_text"
|
android:text="@string/cancel_text"
|
||||||
|
android:textSize="15sp"
|
||||||
app:layout_constraintEnd_toStartOf="@id/next_button"
|
app:layout_constraintEnd_toStartOf="@id/next_button"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
app:layout_constraintTop_toBottomOf="@id/card_view" />
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
<Button
|
<Button
|
||||||
android:id="@+id/can_menu_action"
|
android:id="@+id/can_menu_action"
|
||||||
android:layout_margin="12dp"
|
android:layout_margin="12dp"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"/>
|
||||||
<TextView
|
<TextView
|
||||||
@ -50,13 +50,13 @@
|
|||||||
<Button
|
<Button
|
||||||
android:id="@+id/pin_menu_action"
|
android:id="@+id/pin_menu_action"
|
||||||
android:layout_margin="12dp"
|
android:layout_margin="12dp"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content" />
|
android:layout_height="wrap_content" />
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/pin_menu_show"
|
android:id="@+id/pin_menu_show"
|
||||||
android:layout_margin="12dp"
|
android:layout_margin="12dp"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
@ -70,7 +70,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/return_text"
|
android:text="@string/return_text"
|
||||||
android:layout_margin="24dp"
|
android:layout_margin="24dp"
|
||||||
android:textSize="18sp"
|
android:textSize="15sp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/settings_card"
|
app:layout_constraintTop_toBottomOf="@id/settings_card"
|
||||||
app:layout_constraintStart_toStartOf="parent" />
|
app:layout_constraintStart_toStartOf="parent" />
|
||||||
|
|
||||||
|
@ -57,6 +57,54 @@
|
|||||||
android:textSize="20sp"
|
android:textSize="20sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gender_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/gender_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/gender"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/expiration_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/expiration_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/expiration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/citizenship_label"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="24dp"
|
||||||
|
android:text="@string/citizenship_label"
|
||||||
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/citizenship"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="4dp"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</com.google.android.material.card.MaterialCardView>
|
</com.google.android.material.card.MaterialCardView>
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<string name="user_name_label">NIMI</string>
|
<string name="user_name_label">NIMI</string>
|
||||||
<string name="user_name">%1$s %2$s</string>
|
<string name="user_name">%1$s %2$s</string>
|
||||||
<string name="identification_number_label">ISIKUKOOD</string>
|
<string name="identification_number_label">ISIKUKOOD</string>
|
||||||
|
<string name="expiration_label">KEHTIV KUNI</string>
|
||||||
|
<string name="citizenship_label">KODAKONDSUS</string>
|
||||||
|
<string name="gender_label">SUGU</string>
|
||||||
<string name="clear_button">UNUSTA</string>
|
<string name="clear_button">UNUSTA</string>
|
||||||
|
|
||||||
<!-- menu -->
|
<!-- menu -->
|
||||||
|
@ -44,6 +44,9 @@
|
|||||||
<string name="user_name">%1$s %2$s</string>
|
<string name="user_name">%1$s %2$s</string>
|
||||||
<string name="identification_number_label">ISIKUKOOD</string>
|
<string name="identification_number_label">ISIKUKOOD</string>
|
||||||
<string name="clear_button">UNUSTA</string>
|
<string name="clear_button">UNUSTA</string>
|
||||||
|
<string name="expiration_label">KEHTIV KUNI</string>
|
||||||
|
<string name="citizenship_label">KODAKONDSUS</string>
|
||||||
|
<string name="gender_label">SUGU</string>
|
||||||
|
|
||||||
<!-- menu -->
|
<!-- menu -->
|
||||||
<string name="menu_settings_title">Seaded</string>
|
<string name="menu_settings_title">Seaded</string>
|
||||||
|
@ -43,6 +43,9 @@
|
|||||||
<string name="user_name_label">NIMI</string>
|
<string name="user_name_label">NIMI</string>
|
||||||
<string name="user_name">%1$s %2$s</string>
|
<string name="user_name">%1$s %2$s</string>
|
||||||
<string name="identification_number_label">ISIKUKOOD</string>
|
<string name="identification_number_label">ISIKUKOOD</string>
|
||||||
|
<string name="expiration_label">KEHTIV KUNI</string>
|
||||||
|
<string name="citizenship_label">KODAKONDSUS</string>
|
||||||
|
<string name="gender_label">SUGU</string>
|
||||||
<string name="clear_button">UNUSTA</string>
|
<string name="clear_button">UNUSTA</string>
|
||||||
|
|
||||||
<!-- menu -->
|
<!-- menu -->
|
||||||
|
Loading…
Reference in New Issue
Block a user