SplashFragment: Switch deeplink from AppDetailsFragment to SplashFragment
Ensure every session is a valid one before trying to access the app details Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
This commit is contained in:
@@ -21,9 +21,9 @@ package com.aurora.store.view.ui.splash
|
|||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.fragment.app.Fragment
|
|
||||||
import androidx.fragment.app.activityViewModels
|
import androidx.fragment.app.activityViewModels
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
|
import androidx.navigation.fragment.navArgs
|
||||||
import coil.load
|
import coil.load
|
||||||
import coil.transform.RoundedCornersTransformation
|
import coil.transform.RoundedCornersTransformation
|
||||||
import com.aurora.extensions.hide
|
import com.aurora.extensions.hide
|
||||||
@@ -34,15 +34,17 @@ import com.aurora.store.databinding.FragmentSplashBinding
|
|||||||
import com.aurora.store.util.Preferences
|
import com.aurora.store.util.Preferences
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
|
import com.aurora.store.util.Preferences.PREFERENCE_DEFAULT_SELECTED_TAB
|
||||||
import com.aurora.store.util.Preferences.PREFERENCE_INTRO
|
import com.aurora.store.util.Preferences.PREFERENCE_INTRO
|
||||||
|
import com.aurora.store.view.ui.commons.BaseFragment
|
||||||
import com.aurora.store.viewmodel.auth.AuthViewModel
|
import com.aurora.store.viewmodel.auth.AuthViewModel
|
||||||
|
|
||||||
class SplashFragment : Fragment(R.layout.fragment_splash) {
|
class SplashFragment : BaseFragment(R.layout.fragment_splash) {
|
||||||
|
|
||||||
private var _binding: FragmentSplashBinding? = null
|
private var _binding: FragmentSplashBinding? = null
|
||||||
private val binding: FragmentSplashBinding
|
private val binding: FragmentSplashBinding
|
||||||
get() = _binding!!
|
get() = _binding!!
|
||||||
|
|
||||||
private val viewModel: AuthViewModel by activityViewModels()
|
private val viewModel: AuthViewModel by activityViewModels()
|
||||||
|
private val args: SplashFragmentArgs by navArgs()
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
@@ -90,7 +92,11 @@ class SplashFragment : Fragment(R.layout.fragment_splash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuthState.Valid -> {
|
AuthState.Valid -> {
|
||||||
navigateToDefaultTab()
|
if (args.packageName.isBlank()) {
|
||||||
|
navigateToDefaultTab()
|
||||||
|
} else {
|
||||||
|
openDetailsFragment(args.packageName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthState.Available -> {
|
AuthState.Available -> {
|
||||||
@@ -104,7 +110,11 @@ class SplashFragment : Fragment(R.layout.fragment_splash) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AuthState.SignedIn -> {
|
AuthState.SignedIn -> {
|
||||||
navigateToDefaultTab()
|
if (args.packageName.isBlank()) {
|
||||||
|
navigateToDefaultTab()
|
||||||
|
} else {
|
||||||
|
openDetailsFragment(args.packageName)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
AuthState.SignedOut -> {
|
AuthState.SignedOut -> {
|
||||||
|
|||||||
@@ -170,9 +170,6 @@
|
|||||||
<argument
|
<argument
|
||||||
android:name="packageName"
|
android:name="packageName"
|
||||||
app:argType="string" />
|
app:argType="string" />
|
||||||
<deepLink
|
|
||||||
app:action="android.intent.action.VIEW"
|
|
||||||
app:uri="play.google.com/store/apps/details?id={packageName}" />
|
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_appDetailsFragment_to_devAppsFragment"
|
android:id="@+id/action_appDetailsFragment_to_devAppsFragment"
|
||||||
app:destination="@id/devAppsFragment" />
|
app:destination="@id/devAppsFragment" />
|
||||||
@@ -311,6 +308,13 @@
|
|||||||
android:id="@+id/splashFragment"
|
android:id="@+id/splashFragment"
|
||||||
android:name="com.aurora.store.view.ui.splash.SplashFragment"
|
android:name="com.aurora.store.view.ui.splash.SplashFragment"
|
||||||
tools:layout="@layout/fragment_splash" >
|
tools:layout="@layout/fragment_splash" >
|
||||||
|
<argument
|
||||||
|
android:name="packageName"
|
||||||
|
android:defaultValue=""
|
||||||
|
app:argType="string" />
|
||||||
|
<deepLink
|
||||||
|
app:action="android.intent.action.VIEW"
|
||||||
|
app:uri="play.google.com/store/apps/details?id={packageName}" />
|
||||||
<action
|
<action
|
||||||
android:id="@+id/action_splashFragment_to_navigation_apps"
|
android:id="@+id/action_splashFragment_to_navigation_apps"
|
||||||
app:destination="@id/appsContainerFragment"
|
app:destination="@id/appsContainerFragment"
|
||||||
|
|||||||
Reference in New Issue
Block a user