mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-12-22 12:30:16 +02:00
added more error messages
This commit is contained in:
parent
09c4fa6be3
commit
d4c2a11521
@ -67,7 +67,8 @@ class HomeFragment : Fragment() {
|
||||
// Currently we only support authentication not signing.
|
||||
auth = true
|
||||
}
|
||||
val mobile = requireActivity().intent.getBooleanExtra("mobile", false)
|
||||
var mobile = requireActivity().intent.getBooleanExtra("mobile", false)
|
||||
mobile = true
|
||||
if (auth || mobile) {
|
||||
startAuthentication(mobile)
|
||||
} else {
|
||||
@ -111,15 +112,29 @@ class HomeFragment : Fragment() {
|
||||
intentParams.setAuthUrl(requireActivity().intent.data!!.getQueryParameter("authUrl")!!)
|
||||
intentParams.setOrigin(requireActivity().intent.data!!.getQueryParameter("originUrl")!!)
|
||||
}
|
||||
goToTheNextFragment(mobile)
|
||||
} catch (e: Exception) {
|
||||
// There was a problem with parameters, which means that authentication is not possible.
|
||||
// In that case we will cancel the authentication immediately as it would be waste of the user's time to carry on
|
||||
// before getting an inevitable error.
|
||||
val resultIntent = Intent()
|
||||
requireActivity().setResult(AppCompatActivity.RESULT_CANCELED, resultIntent)
|
||||
requireActivity().finish()
|
||||
val message = MaterialAlertDialogBuilder(requireContext())
|
||||
message.setTitle(getString(R.string.problem_parameters))
|
||||
if (intentParams.challenge == "") {
|
||||
message.setMessage(getString(R.string.problem_challenge))
|
||||
} else if (intentParams.authUrl == "") {
|
||||
message.setMessage(getString(R.string.problem_authurl))
|
||||
} else if (intentParams.origin == "") {
|
||||
message.setMessage(getString(R.string.problem_originurl))
|
||||
} else {
|
||||
message.setMessage(getString(R.string.problem_other))
|
||||
}
|
||||
message.setPositiveButton(getString(R.string.continue_button)) {_, _ ->
|
||||
val resultIntent = Intent()
|
||||
requireActivity().setResult(AppCompatActivity.RESULT_CANCELED, resultIntent)
|
||||
requireActivity().finish()
|
||||
}
|
||||
message.show()
|
||||
}
|
||||
goToTheNextFragment(mobile)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,10 +187,10 @@ class HomeFragment : Fragment() {
|
||||
/**
|
||||
* Displays a help message to the user explaining what the CAN is
|
||||
*/
|
||||
private fun displayMessage() {
|
||||
private fun displayMessage(title: String, message: String) {
|
||||
val dialog = MaterialAlertDialogBuilder(requireContext())
|
||||
.setTitle(getString(R.string.can_question))
|
||||
.setMessage(getString(R.string.can_explanation))
|
||||
.setTitle(title)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.return_text){_, _ -> }
|
||||
.show()
|
||||
val title = dialog.findViewById<TextView>(R.id.alertTitle)
|
||||
@ -200,7 +215,7 @@ class HomeFragment : Fragment() {
|
||||
findNavController().navigate(action)
|
||||
}
|
||||
binding!!.homeHelpButton.setOnClickListener {
|
||||
displayMessage()
|
||||
displayMessage(getString(R.string.can_question), getString(R.string.can_explanation))
|
||||
}
|
||||
binding!!.homeActionButton.visibility = View.VISIBLE
|
||||
binding!!.homeHelpButton.visibility = View.VISIBLE
|
||||
@ -269,7 +284,9 @@ class HomeFragment : Fragment() {
|
||||
|
||||
override fun onDestroyView() {
|
||||
super.onDestroyView()
|
||||
requireActivity().unregisterReceiver(receiver)
|
||||
if (receiver != null) {
|
||||
requireActivity().unregisterReceiver(receiver)
|
||||
}
|
||||
binding = null
|
||||
}
|
||||
}
|
@ -29,7 +29,11 @@
|
||||
<string name="help_text">HELP</string>
|
||||
<string name="can_question">What is CAN?</string>
|
||||
<string name="can_explanation">CAN is a 6 digit code that is needed to communicate with an ID card. It can be found on the ID card under the card holder\'s picture with a title KASUTAJA ALLKIRI/HOLDER\'S SIGNATURE.</string>
|
||||
|
||||
<string name="problem_parameters">Problem with parameters</string>
|
||||
<string name="problem_challenge">Challenge is missing</string>
|
||||
<string name="problem_authurl">AuthUrl is missing</string>
|
||||
<string name="problem_originurl">OriginUrl is missing</string>
|
||||
<string name="problem_other">Unspecified problem with parameters</string>
|
||||
<!-- string resources for PinFragment -->
|
||||
<string name="pin_view">Please enter PIN 1</string>
|
||||
<string name="hint_pin">PIN 1</string>
|
||||
|
@ -28,7 +28,11 @@
|
||||
<string name="help_text">INFO</string>
|
||||
<string name="can_question">Mis on CAN?</string>
|
||||
<string name="can_explanation">CAN on 6 kohaline numbritest koosnev kood, mida on vaja ID kaardiga suhtlemiseks. CAN-i leiab ID kaardilt omaniku pildi alt pealkirjaga KASUTAJA ALLKIRI/HOLDER\'S SIGNATURE.</string>
|
||||
|
||||
<string name="problem_parameters">Probleem parameetritega</string>
|
||||
<string name="problem_challenge">Puudub challenge parameeter</string>
|
||||
<string name="problem_authurl">Puudub AuthUrl parameeter</string>
|
||||
<string name="problem_originurl">Puudub OriginUrl parameeter</string>
|
||||
<string name="problem_other">Täpsustamata probleem parameetritega</string>
|
||||
<!-- string resources for PinFragment -->
|
||||
<string name="pin_view">Palun sisesta PIN 1</string>
|
||||
<string name="hint_pin">PIN 1</string>
|
||||
|
@ -27,7 +27,11 @@
|
||||
<string name="help_text">HELP</string>
|
||||
<string name="can_question">What is CAN?</string>
|
||||
<string name="can_explanation">CAN is a 6 digit code that is needed to communicate with an ID card. It can be found on the ID card under the card holder\'s picture with a title KASUTAJA ALLKIRI/HOLDER\'S SIGNATURE.</string>
|
||||
|
||||
<string name="problem_parameters">Problem with parameters</string>
|
||||
<string name="problem_challenge">Challenge is missing</string>
|
||||
<string name="problem_authurl">AuthUrl is missing</string>
|
||||
<string name="problem_originurl">OriginUrl is missing</string>
|
||||
<string name="problem_other">Unspecified problem with parameters</string>
|
||||
<!-- string resources for PinFragment -->
|
||||
<string name="pin_view">Please enter PIN 1</string>
|
||||
<string name="hint_pin">PIN 1</string>
|
||||
|
Loading…
Reference in New Issue
Block a user