mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] Closes https://github.com/mozilla-mobile/fenix/issues/21759: Do not render home fragment when launching to tab
Co-authored-by: Sebastian Kaspari <s.kaspari@gmail.com>
This commit is contained in:
parent
43c3c127aa
commit
5daf8934ca
@ -132,7 +132,7 @@ import java.lang.ref.WeakReference
|
||||
* - browser screen
|
||||
*/
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
@SuppressWarnings("TooManyFunctions", "LargeClass", "LongParameterList")
|
||||
@SuppressWarnings("TooManyFunctions", "LargeClass", "LongParameterList", "LongMethod")
|
||||
open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
// DO NOT MOVE ANYTHING ABOVE THIS, GETTING INIT TIME IS CRITICAL
|
||||
// we need to store startup timestamp for warm startup. we cant directly store
|
||||
@ -229,12 +229,18 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
it.start()
|
||||
}
|
||||
|
||||
if (!shouldStartOnHome() &&
|
||||
shouldNavigateBrowserFragmentOnColdStart(savedInstanceState)
|
||||
) {
|
||||
// Unless the activity is recreated, navigate to home first (without rendering it)
|
||||
// to add it to the back stack.
|
||||
if (savedInstanceState == null) {
|
||||
navigateToHome()
|
||||
}
|
||||
|
||||
if (!shouldStartOnHome() && shouldNavigateToBrowserOnColdStart(savedInstanceState)) {
|
||||
navigateToBrowserOnColdStart()
|
||||
} else if (FeatureFlags.showStartOnHomeSettings) {
|
||||
components.analytics.metrics.track(Event.StartOnHomeEnterHomeScreen)
|
||||
} else {
|
||||
if (FeatureFlags.showStartOnHomeSettings) {
|
||||
components.analytics.metrics.track(Event.StartOnHomeEnterHomeScreen)
|
||||
}
|
||||
}
|
||||
|
||||
Performance.processIntentIfPerformanceTest(intent, this)
|
||||
@ -879,13 +885,16 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
open fun navigateToBrowserOnColdStart() {
|
||||
// Normal tabs + cold start -> Should go back to browser if we had any tabs open when we left last
|
||||
// except for PBM + Cold Start there won't be any tabs since they're evicted so we never will navigate
|
||||
if (settings().shouldReturnToBrowser &&
|
||||
!browsingModeManager.mode.isPrivate
|
||||
) {
|
||||
if (settings().shouldReturnToBrowser && !browsingModeManager.mode.isPrivate) {
|
||||
// Navigate to home first (without rendering it) to add it to the back stack.
|
||||
openToBrowser(BrowserDirection.FromGlobal, null)
|
||||
}
|
||||
}
|
||||
|
||||
open fun navigateToHome() {
|
||||
navHost.navController.navigate(NavGraphDirections.actionStartupHome())
|
||||
}
|
||||
|
||||
override fun attachBaseContext(base: Context) {
|
||||
base.components.strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
|
||||
super.attachBaseContext(base)
|
||||
@ -1001,7 +1010,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
|
||||
@VisibleForTesting
|
||||
internal fun getSettings(): Settings = settings()
|
||||
|
||||
private fun shouldNavigateBrowserFragmentOnColdStart(savedInstanceState: Bundle?): Boolean {
|
||||
private fun shouldNavigateToBrowserOnColdStart(savedInstanceState: Bundle?): Boolean {
|
||||
return isActivityColdStarted(intent, savedInstanceState) &&
|
||||
!externalSourceIntentProcessors.any {
|
||||
it.process(
|
||||
|
19
app/src/main/java/org/mozilla/fenix/StartupFragment.kt
Normal file
19
app/src/main/java/org/mozilla/fenix/StartupFragment.kt
Normal file
@ -0,0 +1,19 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix
|
||||
|
||||
import androidx.fragment.app.Fragment
|
||||
import org.mozilla.fenix.home.HomeFragment
|
||||
|
||||
/**
|
||||
* This empty fragment serves as a start destination in our navigation
|
||||
* graph. It contains no layout and is fast to create compared to our
|
||||
* [HomeFragment], which would otherwise be the start destination.
|
||||
*
|
||||
* When our [HomeActivity] is created we make a decision which fragment
|
||||
* to navigate to, which makes sure we only render the [HomeFragment]
|
||||
* as needed.
|
||||
*/
|
||||
class StartupFragment : Fragment()
|
@ -53,6 +53,10 @@ open class ExternalAppBrowserActivity : HomeActivity() {
|
||||
// No-op for external app
|
||||
}
|
||||
|
||||
override fun navigateToHome() {
|
||||
// No-op for external app
|
||||
}
|
||||
|
||||
override fun handleNewIntent(intent: Intent) {
|
||||
// No-op for external app
|
||||
}
|
||||
|
@ -3,7 +3,13 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/nav_graph"
|
||||
app:startDestination="@id/homeFragment">
|
||||
app:startDestination="@id/startupFragment">
|
||||
|
||||
<action
|
||||
android:id="@+id/action_startup_home"
|
||||
app:destination="@id/homeFragment"
|
||||
app:popUpTo="@id/startupFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_home"
|
||||
@ -157,6 +163,11 @@
|
||||
app:argType="string" />
|
||||
</dialog>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/startupFragment"
|
||||
android:name="org.mozilla.fenix.StartupFragment">
|
||||
</fragment>
|
||||
|
||||
<fragment
|
||||
android:id="@+id/homeFragment"
|
||||
android:name="org.mozilla.fenix.home.HomeFragment"
|
||||
|
Loading…
Reference in New Issue
Block a user