MOB-40 finished home fragment

This commit is contained in:
Henrik Lepson 2021-12-03 16:11:48 +02:00
parent 716b983389
commit 152fd16162
5 changed files with 44 additions and 0 deletions

View File

@ -13,10 +13,13 @@ import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.navigation.fragment.findNavController
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.tarkvaraprojekt.mobileauthapp.NFC.Comms
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentHomeBinding
import com.tarkvaraprojekt.mobileauthapp.model.ParametersViewModel
@ -166,6 +169,20 @@ class HomeFragment : Fragment() {
displayStates()
}
/**
* Displays a help message to the user explaining what the CAN is
*/
private fun displayMessage() {
val dialog = MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.can_question))
.setMessage(getString(R.string.can_explanation))
.setPositiveButton(R.string.return_text){_, _ -> }
.show()
val title = dialog.findViewById<TextView>(R.id.alertTitle)
title?.textSize = 24F
}
/**
* Informs user whether the ID card can be detected or not.
*/
@ -174,6 +191,7 @@ class HomeFragment : Fragment() {
binding!!.detectionActionText.text = getString(R.string.action_detect)
enableReaderMode()
binding!!.homeActionButton.visibility = View.GONE
binding!!.homeHelpButton.visibility = View.GONE
} else {
binding!!.detectionActionText.text = getString(R.string.action_detect_unavailable)
binding!!.homeActionButton.text = getString(R.string.add_can_text)
@ -181,7 +199,11 @@ class HomeFragment : Fragment() {
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(saving = true, fromhome = true)
findNavController().navigate(action)
}
binding!!.homeHelpButton.setOnClickListener {
displayMessage()
}
binding!!.homeActionButton.visibility = View.VISIBLE
binding!!.homeHelpButton.visibility = View.VISIBLE
}
}

View File

@ -112,4 +112,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/id_card_detection"/>
<Button
android:id="@+id/home_help_button"
android:textSize="@dimen/regular_text"
android:text="@string/help_text"
android:layout_marginTop="@dimen/margin_small"
android:layout_marginStart="@dimen/margin_huge"
android:layout_width="0dp"
android:layout_height="wrap_content"
style="?attr/materialButtonOutlinedStyle"
android:visibility="gone"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/home_action_button"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -26,6 +26,9 @@
<string name="pin_status_negative">PIN 1 not saved</string>
<string name="can_status_saved">CAN saved</string>
<string name="can_status_negative">CAN not saved</string>
<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 resources for PinFragment -->
<string name="pin_view">Please enter PIN 1</string>

View File

@ -25,6 +25,9 @@
<string name="pin_status_negative">PIN 1 ei ole salvestatud</string>
<string name="can_status_saved">CAN on salvestatud</string>
<string name="can_status_negative">CAN ei ole salvestatud</string>
<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 resources for PinFragment -->
<string name="pin_view">Palun sisesta PIN 1</string>

View File

@ -24,6 +24,9 @@
<string name="pin_status_negative">PIN 1 not saved</string>
<string name="can_status_saved">CAN saved</string>
<string name="can_status_negative">CAN not saved</string>
<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 resources for PinFragment -->
<string name="pin_view">Please enter PIN 1</string>