Commit 91023fbd authored by Matthew Finkel's avatar Matthew Finkel
Browse files

Bug 34403: Disable Normal mode by default

parent aec19a1b
Loading
Loading
Loading
Loading
+12 −6
Changes for app/src/main/java/org/mozilla/fenix/HomeActivity.kt: 12 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -653,11 +653,17 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    internal fun getModeFromIntentOrLastKnown(intent: Intent?): BrowsingMode {
        intent?.toSafeIntent()?.let {
            if (it.hasExtra(PRIVATE_BROWSING_MODE)) {
                val startPrivateMode = it.getBooleanExtra(PRIVATE_BROWSING_MODE, false)
                val startPrivateMode = settings().shouldDisableNormalMode ||
                    it.getBooleanExtra(PRIVATE_BROWSING_MODE, settings().openLinksInAPrivateTab)

                return BrowsingMode.fromBoolean(isPrivate = startPrivateMode)
            }
        }
        return settings().lastKnownMode
        return when {
            settings().shouldDisableNormalMode -> BrowsingMode.Private
            settings().openLinksInAPrivateTab -> BrowsingMode.Private
            else -> settings().lastKnownMode
        }
    }

    /**
@@ -674,12 +680,12 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    }

    private fun checkPrivateShortcutEntryPoint(intent: Intent) {
        if (intent.hasExtra(OPEN_TO_SEARCH) &&
            (intent.getStringExtra(OPEN_TO_SEARCH) ==
        val shouldStartPrivate = settings().shouldDisableNormalMode ||
                    intent.getStringExtra(OPEN_TO_SEARCH) ==
                    StartSearchIntentProcessor.STATIC_SHORTCUT_NEW_PRIVATE_TAB ||
                    intent.getStringExtra(OPEN_TO_SEARCH) ==
                    StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT)
        ) {
                    StartSearchIntentProcessor.PRIVATE_BROWSING_PINNED_SHORTCUT
        if (intent.hasExtra(OPEN_TO_SEARCH) && shouldStartPrivate) {
            PrivateNotificationService.isStartedFromPrivateShortcut = true
        }
    }
+11 −1
Changes for app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt: 11 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -867,7 +867,17 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
        }
        hideToolbar()

        getSessionById()?.let { updateThemeForSession(it) }
        getSessionById()?.let {
            // If the most-recent session was a tab in Normal mode, and now Normal mode is disabled,
            // then load the Private Mode home screen, instead.
            if (!it.private && requireContext().settings().shouldDisableNormalMode) {
                findNavController().nav(
                    R.id.browserFragment,
                    BrowserFragmentDirections.actionGlobalHomeFragment()
                )
            }
            updateThemeForSession(it)
        }
    }

    @CallSuper
+2 −1
Changes for app/src/main/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenu.kt: 2 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -178,7 +178,8 @@ class DefaultToolbarMenu(
        val shouldShowSaveToCollection = (context.asActivity() as? HomeActivity)
            ?.browsingModeManager?.mode == BrowsingMode.Normal
        val shouldDeleteDataOnQuit = context.components.settings
            .shouldDeleteBrowsingDataOnQuit
            .shouldDeleteBrowsingDataOnQuit &&
            !context.components.settings.shouldDisableNormalMode
        val syncedTabsInTabsTray = context.components.settings
            .syncedTabsInTabsTray

+3 −0
Changes for app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import androidx.constraintlayout.widget.ConstraintSet.TOP
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.view.doOnLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.core.view.updateLayoutParams
import androidx.fragment.app.Fragment
@@ -427,6 +428,8 @@ class HomeFragment : Fragment() {
            }
        }

        privateBrowsingButton.isGone = view.context.settings().shouldDisableNormalMode

        // We call this onLayout so that the bottom bar width is correctly set for us to center
        // the CFR in.
        view.toolbar_wrapper.doOnLayout {
+3 −1
Changes for app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -161,9 +161,11 @@ class HomeMenu(
        }

        val settings = context.components.settings
        val shouldDeleteBrowsingDataOnQuit = settings.shouldDeleteBrowsingDataOnQuit &&
            !settings.shouldDisableNormalMode

        val menuItems = listOfNotNull(
            if (settings.shouldDeleteBrowsingDataOnQuit) quitItem else null,
            if (shouldDeleteBrowsingDataOnQuit) quitItem else null,
            settingsItem,
            BrowserMenuDivider(),
            if (settings.syncedTabsInTabsTray) null else syncedTabsItem,
Loading