From 152fd16162269c74d32052caef1fdb27be2ea41f Mon Sep 17 00:00:00 2001 From: Henrik Lepson Date: Fri, 3 Dec 2021 16:11:48 +0200 Subject: [PATCH] MOB-40 finished home fragment --- .../mobileauthapp/HomeFragment.kt | 22 +++++++++++++++++++ .../app/src/main/res/layout/fragment_home.xml | 13 +++++++++++ .../app/src/main/res/values-en/strings.xml | 3 +++ .../app/src/main/res/values-et/strings.xml | 3 +++ .../app/src/main/res/values/strings.xml | 3 +++ 5 files changed, 44 insertions(+) diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt index 8b85518..659d131 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt @@ -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(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 } } diff --git a/MobileAuthApp/app/src/main/res/layout/fragment_home.xml b/MobileAuthApp/app/src/main/res/layout/fragment_home.xml index 163c5eb..899d161 100644 --- a/MobileAuthApp/app/src/main/res/layout/fragment_home.xml +++ b/MobileAuthApp/app/src/main/res/layout/fragment_home.xml @@ -112,4 +112,17 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/id_card_detection"/> +