From 364fc7c45ba0a8c8f2c86553711b00b1eb8ce5f7 Mon Sep 17 00:00:00 2001 From: Henrik Lepson Date: Thu, 21 Oct 2021 21:22:11 +0300 Subject: [PATCH 1/7] MOB-40 started to create UI for auth when launched with intent --- .../mobileauthapp/AuthFragment.kt | 13 ++++--- .../mobileauthapp/CanFragment.kt | 5 +-- .../mobileauthapp/HomeFragment.kt | 16 +++++++-- .../mobileauthapp/PinFragment.kt | 3 +- .../mobileauthapp/ResultFragment.kt | 36 +++++++++++++++++++ .../src/main/res/layout/fragment_result.xml | 34 ++++++++++++++++++ .../app/src/main/res/navigation/nav_graph.xml | 21 +++++++++++ .../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 | 5 +++ 10 files changed, 128 insertions(+), 11 deletions(-) create mode 100644 MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt create mode 100644 MobileAuthApp/app/src/main/res/layout/fragment_result.xml diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt index ab14a76..23924ec 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt @@ -1,23 +1,20 @@ package com.tarkvaraprojekt.mobileauthapp -import android.app.Activity -import android.content.Context import android.nfc.NfcAdapter import android.nfc.tech.IsoDep import android.os.Bundle import android.os.CountDownTimer -import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController +import androidx.navigation.fragment.navArgs import com.tarkvaraprojekt.mobileauthapp.NFC.Comms import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentAuthBinding import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel import java.lang.Exception -import kotlin.concurrent.thread /** * Fragment that asks the user to detect the ID card with mobile NFC chip. @@ -30,6 +27,8 @@ class AuthFragment : Fragment() { private var binding: FragmentAuthBinding? = null + private val args: CanFragmentArgs by navArgs() + private lateinit var timer: CountDownTimer private var timeRemaining: Int = 90 @@ -106,7 +105,11 @@ class AuthFragment : Fragment() { private fun goToNextFragment() { timer.cancel() - findNavController().navigate(R.id.action_authFragment_to_userFragment) + if (args.auth) { + findNavController().navigate(R.id.action_authFragment_to_resultFragment) + } else { + findNavController().navigate(R.id.action_authFragment_to_userFragment) + } } private fun goToTheStart() { diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt index cdf9e4e..b65e89c 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt @@ -65,7 +65,7 @@ class CanFragment : Fragment() { * Takes user to the next fragment, which is PinFragment. */ private fun goToTheNextFragment() { - val action = CanFragmentDirections.actionCanFragmentToPinFragment(reading = args.reading) + val action = CanFragmentDirections.actionCanFragmentToPinFragment(reading = args.reading, auth = args.auth) findNavController().navigate(action) } @@ -122,7 +122,8 @@ class CanFragment : Fragment() { * not the HomeFragment. */ private fun goToTheStart() { - if (args.saving) { + // TODO: Needs special handling when the app is launched with intent. Temporary solution at the moment. + if (args.saving || args.auth) { findNavController().navigate(R.id.action_canFragment_to_settingsFragment) } else { findNavController().navigate(R.id.action_canFragment_to_homeFragment) 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 77a2552..e7c6b4a 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt @@ -37,6 +37,10 @@ class HomeFragment : Fragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) initialChecks() + // TODO: If app launched with intent then go to the CanFragment immediately. + if (true){ // Currently true for testing purposes + goToTheNextFragment(true) + } binding!!.beginButton.setOnClickListener { goToTheNextFragment() } } @@ -52,13 +56,19 @@ class HomeFragment : Fragment() { /** * Starts the process of interacting with the ID card by sending user to the CAN fragment. */ - private fun goToTheNextFragment() { + private fun goToTheNextFragment(auth: Boolean = false) { // Making settings menu inactive (activity as MainActivity).menuAvailable = false // Currently saving is true because the application is not yet integrated with // other applications or websites. - val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = true) - findNavController().navigate(action) + // TODO: Check the navigation action default values. Not everything has to be declared implicitly. + if (auth) { + val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = false, auth = true) + findNavController().navigate(action) + } else { + val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = true, auth = false) + findNavController().navigate(action) + } } /** diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt index 68b6355..33f730d 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt @@ -68,7 +68,8 @@ class PinFragment : Fragment() { * Takes user to the next fragment, which is AuthFragment. */ private fun goToTheNextFragment() { - findNavController().navigate(R.id.action_pinFragment_to_authFragment) + val action = PinFragmentDirections.actionPinFragmentToAuthFragment(auth = args.auth) + findNavController().navigate(action) } /** diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt new file mode 100644 index 0000000..4cf541a --- /dev/null +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt @@ -0,0 +1,36 @@ +package com.tarkvaraprojekt.mobileauthapp + +import android.os.Bundle +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.fragment.app.activityViewModels +import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentResultBinding +import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel + +/** + * ResultFragment is used to create a JWT and to send response to the website/application + * that launched the MobileAuthApp. + */ +class ResultFragment : Fragment() { + + private val viewModel: SmartCardViewModel by activityViewModels() + + private var binding: FragmentResultBinding? = null + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + binding = FragmentResultBinding.inflate(inflater, container, false) + return binding!!.root + } + + override fun onDestroy() { + super.onDestroy() + binding = null + } + +} \ No newline at end of file diff --git a/MobileAuthApp/app/src/main/res/layout/fragment_result.xml b/MobileAuthApp/app/src/main/res/layout/fragment_result.xml new file mode 100644 index 0000000..81ac62a --- /dev/null +++ b/MobileAuthApp/app/src/main/res/layout/fragment_result.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/MobileAuthApp/app/src/main/res/navigation/nav_graph.xml b/MobileAuthApp/app/src/main/res/navigation/nav_graph.xml index 39fe753..40bfc92 100644 --- a/MobileAuthApp/app/src/main/res/navigation/nav_graph.xml +++ b/MobileAuthApp/app/src/main/res/navigation/nav_graph.xml @@ -46,6 +46,10 @@ android:name="reading" app:argType="boolean" android:defaultValue="false" /> + + + + + \ No newline at end of file diff --git a/MobileAuthApp/app/src/main/res/values-en/strings.xml b/MobileAuthApp/app/src/main/res/values-en/strings.xml index 8572c9c..52d67e2 100644 --- a/MobileAuthApp/app/src/main/res/values-en/strings.xml +++ b/MobileAuthApp/app/src/main/res/values-en/strings.xml @@ -50,6 +50,9 @@ SUGU UNUSTA + + See Fragment vastutab vastuse tagastamise eest. + Seaded Keel diff --git a/MobileAuthApp/app/src/main/res/values-et/strings.xml b/MobileAuthApp/app/src/main/res/values-et/strings.xml index 676b5c9..51a02a9 100644 --- a/MobileAuthApp/app/src/main/res/values-et/strings.xml +++ b/MobileAuthApp/app/src/main/res/values-et/strings.xml @@ -48,6 +48,9 @@ KODAKONDSUS SUGU + + See Fragment vastutab vastuse tagastamise eest. + Seaded Keel diff --git a/MobileAuthApp/app/src/main/res/values/strings.xml b/MobileAuthApp/app/src/main/res/values/strings.xml index 26fddf6..cf97dc1 100644 --- a/MobileAuthApp/app/src/main/res/values/strings.xml +++ b/MobileAuthApp/app/src/main/res/values/strings.xml @@ -48,6 +48,9 @@ SUGU UNUSTA + + See Fragment vastutab vastuse tagastamise eest. + Seaded Keel @@ -63,4 +66,6 @@ PEIDA **** Seaded pole hetkel saadaval + + Hello blank fragment \ No newline at end of file From a9336b790fcc9c041d435bb3cb5a4f04af903913 Mon Sep 17 00:00:00 2001 From: Henrik Lepson Date: Tue, 26 Oct 2021 11:42:58 +0300 Subject: [PATCH 2/7] MOB-41 created a base for app that can launch authapp --- .../mobileauthapp/AuthFragment.kt | 11 +- .../mobileauthapp/CanFragment.kt | 8 +- .../mobileauthapp/HomeFragment.kt | 4 +- .../mobileauthapp/PinFragment.kt | 13 +- .../mobileauthapp/ResultFragment.kt | 15 ++ .../src/main/res/layout/fragment_result.xml | 25 +++ .../app/src/main/res/navigation/nav_graph.xml | 4 + .../app/src/main/res/values-en/strings.xml | 1 + .../app/src/main/res/values-et/strings.xml | 1 + .../app/src/main/res/values/strings.xml | 1 + TestMobileApp/.gitignore | 16 ++ TestMobileApp/app/.gitignore | 1 + TestMobileApp/app/build.gradle | 46 +++++ TestMobileApp/app/proguard-rules.pro | 21 ++ .../testmobileapp/ExampleInstrumentedTest.kt | 24 +++ .../app/src/main/AndroidManifest.xml | 23 +++ .../com/example/testmobileapp/MainActivity.kt | 41 ++++ .../drawable-v24/ic_launcher_foreground.xml | 30 +++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++ .../app/src/main/res/layout/activity_main.xml | 49 +++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 5 + .../mipmap-anydpi-v26/ic_launcher_round.xml | 5 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes .../app/src/main/res/values-night/themes.xml | 16 ++ .../app/src/main/res/values/colors.xml | 17 ++ .../app/src/main/res/values/strings.xml | 8 + .../app/src/main/res/values/themes.xml | 16 ++ .../example/testmobileapp/ExampleUnitTest.kt | 17 ++ TestMobileApp/build.gradle | 18 ++ TestMobileApp/gradle.properties | 21 ++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 59203 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + TestMobileApp/gradlew | 185 ++++++++++++++++++ TestMobileApp/gradlew.bat | 89 +++++++++ TestMobileApp/settings.gradle | 10 + 44 files changed, 910 insertions(+), 7 deletions(-) create mode 100644 TestMobileApp/.gitignore create mode 100644 TestMobileApp/app/.gitignore create mode 100644 TestMobileApp/app/build.gradle create mode 100644 TestMobileApp/app/proguard-rules.pro create mode 100644 TestMobileApp/app/src/androidTest/java/com/example/testmobileapp/ExampleInstrumentedTest.kt create mode 100644 TestMobileApp/app/src/main/AndroidManifest.xml create mode 100644 TestMobileApp/app/src/main/java/com/example/testmobileapp/MainActivity.kt create mode 100644 TestMobileApp/app/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 TestMobileApp/app/src/main/res/drawable/ic_launcher_background.xml create mode 100644 TestMobileApp/app/src/main/res/layout/activity_main.xml create mode 100644 TestMobileApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml create mode 100644 TestMobileApp/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml create mode 100644 TestMobileApp/app/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 TestMobileApp/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 TestMobileApp/app/src/main/res/values-night/themes.xml create mode 100644 TestMobileApp/app/src/main/res/values/colors.xml create mode 100644 TestMobileApp/app/src/main/res/values/strings.xml create mode 100644 TestMobileApp/app/src/main/res/values/themes.xml create mode 100644 TestMobileApp/app/src/test/java/com/example/testmobileapp/ExampleUnitTest.kt create mode 100644 TestMobileApp/build.gradle create mode 100644 TestMobileApp/gradle.properties create mode 100644 TestMobileApp/gradle/wrapper/gradle-wrapper.jar create mode 100644 TestMobileApp/gradle/wrapper/gradle-wrapper.properties create mode 100644 TestMobileApp/gradlew create mode 100644 TestMobileApp/gradlew.bat create mode 100644 TestMobileApp/settings.gradle diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt index 23924ec..706aaca 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/AuthFragment.kt @@ -1,12 +1,15 @@ package com.tarkvaraprojekt.mobileauthapp +import android.content.Intent import android.nfc.NfcAdapter import android.nfc.tech.IsoDep import android.os.Bundle import android.os.CountDownTimer +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController @@ -115,7 +118,13 @@ class AuthFragment : Fragment() { private fun goToTheStart() { viewModel.clearUserInfo() timer.cancel() - findNavController().navigate(R.id.action_authFragment_to_homeFragment) + if (args.reading) { + findNavController().navigate(R.id.action_authFragment_to_homeFragment) + } else { + val resultIntent = Intent() + requireActivity().setResult(AppCompatActivity.RESULT_CANCELED, resultIntent) + requireActivity().finish() + } } override fun onDestroy() { diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt index b65e89c..f73b243 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/CanFragment.kt @@ -1,11 +1,13 @@ package com.tarkvaraprojekt.mobileauthapp import android.app.AlertDialog +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController @@ -123,8 +125,12 @@ class CanFragment : Fragment() { */ private fun goToTheStart() { // TODO: Needs special handling when the app is launched with intent. Temporary solution at the moment. - if (args.saving || args.auth) { + if (args.saving) { findNavController().navigate(R.id.action_canFragment_to_settingsFragment) + } else if (args.auth) { + val resultIntent = Intent() + requireActivity().setResult(AppCompatActivity.RESULT_CANCELED, resultIntent) + requireActivity().finish() } else { findNavController().navigate(R.id.action_canFragment_to_homeFragment) } 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 e7c6b4a..318f25d 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/HomeFragment.kt @@ -1,6 +1,7 @@ package com.tarkvaraprojekt.mobileauthapp import android.os.Bundle +import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup @@ -38,7 +39,8 @@ class HomeFragment : Fragment() { super.onViewCreated(view, savedInstanceState) initialChecks() // TODO: If app launched with intent then go to the CanFragment immediately. - if (true){ // Currently true for testing purposes + val auth = requireActivity().intent.getBooleanExtra("auth", false) + if (auth){ // Currently true for testing purposes goToTheNextFragment(true) } binding!!.beginButton.setOnClickListener { goToTheNextFragment() } diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt index 33f730d..7bace11 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/PinFragment.kt @@ -1,11 +1,13 @@ package com.tarkvaraprojekt.mobileauthapp import android.app.AlertDialog +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import android.widget.Toast +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController @@ -68,7 +70,7 @@ class PinFragment : Fragment() { * Takes user to the next fragment, which is AuthFragment. */ private fun goToTheNextFragment() { - val action = PinFragmentDirections.actionPinFragmentToAuthFragment(auth = args.auth) + val action = PinFragmentDirections.actionPinFragmentToAuthFragment(reading = args.reading, auth = args.auth) findNavController().navigate(action) } @@ -125,10 +127,13 @@ class PinFragment : Fragment() { */ private fun goToTheStart() { if (args.saving) { - findNavController().navigate(R.id.action_pinFragment_to_settingsFragment) + findNavController().navigate(R.id.action_canFragment_to_settingsFragment) + } else if (args.auth) { + val resultIntent = Intent() + requireActivity().setResult(AppCompatActivity.RESULT_CANCELED, resultIntent) + requireActivity().finish() } else { - viewModel.clearUserInfo() - findNavController().navigate(R.id.action_pinFragment_to_homeFragment) + findNavController().navigate(R.id.action_canFragment_to_homeFragment) } } diff --git a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt index 4cf541a..c510048 100644 --- a/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt +++ b/MobileAuthApp/app/src/main/java/com/tarkvaraprojekt/mobileauthapp/ResultFragment.kt @@ -1,9 +1,11 @@ package com.tarkvaraprojekt.mobileauthapp +import android.content.Intent import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentResultBinding @@ -28,6 +30,19 @@ class ResultFragment : Fragment() { return binding!!.root } + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding!!.resultBackButton.setOnClickListener { + createResponse() + } + } + + private fun createResponse() { + val resultIntent = Intent() + requireActivity().setResult(AppCompatActivity.RESULT_OK, resultIntent) + requireActivity().finish() + } + override fun onDestroy() { super.onDestroy() binding = null diff --git a/MobileAuthApp/app/src/main/res/layout/fragment_result.xml b/MobileAuthApp/app/src/main/res/layout/fragment_result.xml index 81ac62a..1bff4c1 100644 --- a/MobileAuthApp/app/src/main/res/layout/fragment_result.xml +++ b/MobileAuthApp/app/src/main/res/layout/fragment_result.xml @@ -19,14 +19,39 @@ app:strokeColor="@color/stroke_color" app:cardElevation="0dp"> + + + + +