set progress text
This commit is contained in:
parent
e3d3649dd2
commit
c46e8e8277
@ -1,6 +1,5 @@
|
||||
package com.bshield.cccc
|
||||
|
||||
import android.R
|
||||
import android.app.DatePickerDialog
|
||||
import android.content.IntentFilter
|
||||
import android.nfc.NfcAdapter
|
||||
@ -11,7 +10,7 @@ import android.nfc.tech.TagTechnology
|
||||
import android.os.Bundle
|
||||
import android.text.InputType
|
||||
import android.view.View
|
||||
import android.widget.EditText
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.bshield.cccc.databinding.ActivityMainBinding
|
||||
import java.util.*
|
||||
@ -121,6 +120,11 @@ class MainActivity : AppCompatActivity() {
|
||||
// binding.sampleText.text = "nfc enabled? ${nfcAdapter.isEnabled()}"
|
||||
}
|
||||
|
||||
private fun setError(value: String) {
|
||||
runOnUiThread { binding.error.text = value }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A native method that is implemented by the 'cccc' native library,
|
||||
* which is packaged with this application.
|
||||
@ -142,15 +146,15 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
if (binding.idnumber.text.length != 12) {
|
||||
binding.error.text = "ID number must be 12 digits";
|
||||
setError("ID number must be 12 digits");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!::birthday.isInitialized) {
|
||||
binding.error.text = "Birthday is not entered";
|
||||
setError("Birthday is not entered");
|
||||
}
|
||||
if (!::expirydate.isInitialized) {
|
||||
binding.error.text = "Birthday is not entered";
|
||||
setError("Birthday is not entered");
|
||||
}
|
||||
|
||||
val id = binding.idnumber.text.substring(3);
|
||||
@ -170,6 +174,17 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
val passcode = id + checkdigit(id) + birthday + checkdigit(birthday) + expirydate + checkdigit(expirydate);
|
||||
val r = initNFCScan(tagTechnology!!, passcode);
|
||||
|
||||
try {
|
||||
setError("Scanning the identity card");
|
||||
if (initNFCScan(tagTechnology!!, passcode)) {
|
||||
setError("Validated the identity card");
|
||||
}
|
||||
else {
|
||||
setError("Identity card is not validated");
|
||||
}
|
||||
} catch (e: Error) {
|
||||
setError("Error occurred when reading the card: $e");
|
||||
}
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@
|
||||
android:id="@+id/error"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hello World!"
|
||||
android:hint="No Error Found"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
|
Loading…
Reference in New Issue
Block a user