1
0
Fork 0

Fixes Crash: Pop up to Browser Fragment if exists when coming from Search

master
Emily Kager 2019-05-30 15:05:34 -07:00 committed by Jeff Boek
parent 8dbed67f7f
commit 18cd9e58f9
3 changed files with 16 additions and 9 deletions

View File

@ -187,8 +187,13 @@ open class HomeActivity : AppCompatActivity() {
val directions = when (from) {
BrowserDirection.FromGlobal -> NavGraphDirections.actionGlobalBrowser(customTabSessionId)
BrowserDirection.FromHome -> HomeFragmentDirections.actionHomeFragmentToBrowserFragment(customTabSessionId)
BrowserDirection.FromSearch ->
SearchFragmentDirections.actionSearchFragmentToBrowserFragment(customTabSessionId)
BrowserDirection.FromSearch -> {
if (!navHost.navController.popBackStack(R.id.browserFragment, false)) {
SearchFragmentDirections.actionSearchFragmentToBrowserFragment(customTabSessionId)
} else {
null
}
}
BrowserDirection.FromSettings ->
SettingsFragmentDirections.actionSettingsFragmentToBrowserFragment(customTabSessionId)
BrowserDirection.FromBookmarks ->
@ -208,7 +213,9 @@ open class HomeActivity : AppCompatActivity() {
if (sessionObserver == null)
sessionObserver = subscribeToSessions()
navHost.navController.navigate(directions)
directions?.let {
navHost.navController.navigate(it)
}
}
private fun load(searchTermOrURL: String, newTab: Boolean, engine: SearchEngine?, forceSearch: Boolean) {

View File

@ -120,6 +120,10 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
postponeEnterTransition()
sharedElementEnterTransition =
TransitionInflater.from(context).inflateTransition(android.R.transition.move).setDuration(
SHARED_TRANSITION_MS
)
job = Job()
}
@ -180,11 +184,6 @@ class BrowserFragment : Fragment(), BackHandler, CoroutineScope {
)
}
}
sharedElementEnterTransition =
TransitionInflater.from(context).inflateTransition(android.R.transition.move).setDuration(
SHARED_TRANSITION_MS
)
startPostponedEnterTransition()
QuickActionComponent(

View File

@ -58,7 +58,8 @@
<action
android:id="@+id/action_searchFragment_to_browserFragment"
app:destination="@id/browserFragment"
app:popUpTo="@id/homeFragment" />
app:popUpTo="@id/searchFragment"
app:popUpToInclusive="true" />
<argument
android:name="session_id"
app:argType="string"