mirror of
https://github.com/TanelOrumaa/Estonian-ID-card-mobile-authenticator-POC.git
synced 2024-11-04 21:11:00 +02:00
MOB-42 app can be launched with deep links
This commit is contained in:
parent
08430c897c
commit
cc3a3c10d6
@ -19,6 +19,13 @@
|
|||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
<!-- for launching the app with deep links -->
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
|
<category android:name="android.intent.category.BROWSABLE" />
|
||||||
|
<data android:scheme="authapp" android:host="start" android:path="/" />
|
||||||
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
@ -109,7 +109,8 @@ class AuthFragment : Fragment() {
|
|||||||
private fun goToNextFragment() {
|
private fun goToNextFragment() {
|
||||||
timer.cancel()
|
timer.cancel()
|
||||||
if (args.auth) {
|
if (args.auth) {
|
||||||
findNavController().navigate(R.id.action_authFragment_to_resultFragment)
|
val action = AuthFragmentDirections.actionAuthFragmentToResultFragment(mobile = args.mobile)
|
||||||
|
findNavController().navigate(action)
|
||||||
} else {
|
} else {
|
||||||
findNavController().navigate(R.id.action_authFragment_to_userFragment)
|
findNavController().navigate(R.id.action_authFragment_to_userFragment)
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ class CanFragment : Fragment() {
|
|||||||
* Takes user to the next fragment, which is PinFragment.
|
* Takes user to the next fragment, which is PinFragment.
|
||||||
*/
|
*/
|
||||||
private fun goToTheNextFragment() {
|
private fun goToTheNextFragment() {
|
||||||
val action = CanFragmentDirections.actionCanFragmentToPinFragment(reading = args.reading, auth = args.auth)
|
val action = CanFragmentDirections.actionCanFragmentToPinFragment(reading = args.reading, auth = args.auth, mobile = args.mobile)
|
||||||
findNavController().navigate(action)
|
findNavController().navigate(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.tarkvaraprojekt.mobileauthapp
|
package com.tarkvaraprojekt.mobileauthapp
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
@ -38,10 +39,13 @@ class HomeFragment : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
initialChecks()
|
initialChecks()
|
||||||
// TODO: If app launched with intent then go to the CanFragment immediately.
|
var mobile = false
|
||||||
|
if (requireActivity().intent.data?.getQueryParameter("arg1") != null) {
|
||||||
|
mobile = true
|
||||||
|
}
|
||||||
val auth = requireActivity().intent.getBooleanExtra("auth", false)
|
val auth = requireActivity().intent.getBooleanExtra("auth", false)
|
||||||
if (auth){
|
if (auth || mobile){
|
||||||
goToTheNextFragment(true)
|
goToTheNextFragment(true, mobile)
|
||||||
}
|
}
|
||||||
binding!!.beginButton.setOnClickListener { goToTheNextFragment() }
|
binding!!.beginButton.setOnClickListener { goToTheNextFragment() }
|
||||||
}
|
}
|
||||||
@ -58,17 +62,17 @@ class HomeFragment : Fragment() {
|
|||||||
/**
|
/**
|
||||||
* Starts the process of interacting with the ID card by sending user to the CAN fragment.
|
* Starts the process of interacting with the ID card by sending user to the CAN fragment.
|
||||||
*/
|
*/
|
||||||
private fun goToTheNextFragment(auth: Boolean = false) {
|
private fun goToTheNextFragment(auth: Boolean = false, mobile: Boolean = false) {
|
||||||
// Making settings menu inactive
|
// Making settings menu inactive
|
||||||
(activity as MainActivity).menuAvailable = false
|
(activity as MainActivity).menuAvailable = false
|
||||||
// Currently saving is true because the application is not yet integrated with
|
// Currently saving is true because the application is not yet integrated with
|
||||||
// other applications or websites.
|
// other applications or websites.
|
||||||
// TODO: Check the navigation action default values. Not everything has to be declared implicitly.
|
// TODO: Check the navigation action default values. Not everything has to be declared implicitly.
|
||||||
if (auth) {
|
if (auth) {
|
||||||
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = false, auth = true)
|
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = false, auth = true, mobile = mobile)
|
||||||
findNavController().navigate(action)
|
findNavController().navigate(action)
|
||||||
} else {
|
} else {
|
||||||
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = true, auth = false)
|
val action = HomeFragmentDirections.actionHomeFragmentToCanFragment(reading = true, auth = false, mobile = mobile)
|
||||||
findNavController().navigate(action)
|
findNavController().navigate(action)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class PinFragment : Fragment() {
|
|||||||
* Takes user to the next fragment, which is AuthFragment.
|
* Takes user to the next fragment, which is AuthFragment.
|
||||||
*/
|
*/
|
||||||
private fun goToTheNextFragment() {
|
private fun goToTheNextFragment() {
|
||||||
val action = PinFragmentDirections.actionPinFragmentToAuthFragment(reading = args.reading, auth = args.auth)
|
val action = PinFragmentDirections.actionPinFragmentToAuthFragment(reading = args.reading, auth = args.auth, mobile = args.mobile)
|
||||||
findNavController().navigate(action)
|
findNavController().navigate(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,12 +2,14 @@ package com.tarkvaraprojekt.mobileauthapp
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.util.Log
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
|
import androidx.navigation.fragment.navArgs
|
||||||
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentResultBinding
|
import com.tarkvaraprojekt.mobileauthapp.databinding.FragmentResultBinding
|
||||||
import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel
|
import com.tarkvaraprojekt.mobileauthapp.model.SmartCardViewModel
|
||||||
|
|
||||||
@ -22,6 +24,8 @@ class ResultFragment : Fragment() {
|
|||||||
|
|
||||||
private var binding: FragmentResultBinding? = null
|
private var binding: FragmentResultBinding? = null
|
||||||
|
|
||||||
|
private val args: CanFragmentArgs by navArgs()
|
||||||
|
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
inflater: LayoutInflater,
|
inflater: LayoutInflater,
|
||||||
container: ViewGroup?,
|
container: ViewGroup?,
|
||||||
|
@ -50,6 +50,10 @@
|
|||||||
android:name="auth"
|
android:name="auth"
|
||||||
app:argType="boolean"
|
app:argType="boolean"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<argument
|
||||||
|
android:name="mobile"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="false" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/canFragment"
|
android:id="@+id/canFragment"
|
||||||
@ -82,6 +86,10 @@
|
|||||||
android:name="auth"
|
android:name="auth"
|
||||||
app:argType="boolean"
|
app:argType="boolean"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<argument
|
||||||
|
android:name="mobile"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="false" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/authFragment"
|
android:id="@+id/authFragment"
|
||||||
@ -109,6 +117,10 @@
|
|||||||
android:name="reading"
|
android:name="reading"
|
||||||
app:argType="boolean"
|
app:argType="boolean"
|
||||||
android:defaultValue="false" />
|
android:defaultValue="false" />
|
||||||
|
<argument
|
||||||
|
android:name="mobile"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="false" />
|
||||||
</fragment>
|
</fragment>
|
||||||
<fragment
|
<fragment
|
||||||
android:id="@+id/userFragment"
|
android:id="@+id/userFragment"
|
||||||
@ -142,5 +154,10 @@
|
|||||||
android:id="@+id/resultFragment"
|
android:id="@+id/resultFragment"
|
||||||
android:name="com.tarkvaraprojekt.mobileauthapp.ResultFragment"
|
android:name="com.tarkvaraprojekt.mobileauthapp.ResultFragment"
|
||||||
android:label="fragment_result"
|
android:label="fragment_result"
|
||||||
tools:layout="@layout/fragment_result" />
|
tools:layout="@layout/fragment_result" >
|
||||||
|
<argument
|
||||||
|
android:name="mobile"
|
||||||
|
app:argType="boolean"
|
||||||
|
android:defaultValue="false" />
|
||||||
|
</fragment>
|
||||||
</navigation>
|
</navigation>
|
Loading…
Reference in New Issue
Block a user