Commit e8c926f5 authored by Matthew Finkel's avatar Matthew Finkel Committed by Pier Angelo Vendrame
Browse files

TB 34403 [android]: Disable Normal mode by default.

Originally, fenix#34403.
parent 12f4bf31
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -1133,11 +1133,16 @@ 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
        }
    }

    /**
+6 −5
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import mozilla.components.feature.search.ext.createApplicationSearchEngine
import mozilla.components.lib.state.Middleware
import mozilla.components.lib.state.MiddlewareContext
import mozilla.components.lib.state.Store
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.R

const val HISTORY_SEARCH_ENGINE_ID = "history_search_engine_id"
@@ -34,18 +35,18 @@ const val TABS_SEARCH_ENGINE_ID = "tabs_search_engine_id"
 * @param scope [CoroutineScope] used to launch coroutines.
 */
class ApplicationSearchMiddleware(
    context: Context,
    private val context: Context,
    private val stringProvider: (Int) -> String = { context.getString(it) },
    private val bitmapProvider: (Int) -> Bitmap = { getDrawable(context, it)?.toBitmap()!! },
    private val scope: CoroutineScope = CoroutineScope(Dispatchers.IO),
) : Middleware<BrowserState, BrowserAction> {
    override fun invoke(
        context: MiddlewareContext<BrowserState, BrowserAction>,
        middlewareContext: MiddlewareContext<BrowserState, BrowserAction>,
        next: (BrowserAction) -> Unit,
        action: BrowserAction,
    ) {
        if (action is InitAction) {
            loadSearchEngines(context.store)
            loadSearchEngines(middlewareContext.store)
        }

        next(action)
@@ -54,7 +55,7 @@ class ApplicationSearchMiddleware(
    private fun loadSearchEngines(
        store: Store<BrowserState, BrowserAction>,
    ) = scope.launch {
        val searchEngines = listOf(
        val searchEngines = listOfNotNull(
            createApplicationSearchEngine(
                id = BOOKMARKS_SEARCH_ENGINE_ID,
                name = stringProvider(R.string.library_bookmarks),
@@ -72,7 +73,7 @@ class ApplicationSearchMiddleware(
                name = stringProvider(R.string.library_history),
                url = "",
                icon = bitmapProvider(R.drawable.ic_history_search),
            ),
            ).takeIf { !context.settings().shouldDisableNormalMode },
        )

        store.dispatch(SearchAction.ApplicationSearchEnginesLoaded(searchEngines))
+1 −1
Original line number Diff line number Diff line
@@ -434,7 +434,7 @@ open class DefaultToolbarMenu(
                newTabItem,
                BrowserMenuDivider(),
                bookmarksItem,
                historyItem,
                if (context.settings().shouldDisableNormalMode) null else historyItem,
                downloadsItem,
                passwordsItem,
                extensionsItem,
+3 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import androidx.compose.ui.viewinterop.AndroidView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat.getColor
import androidx.core.graphics.drawable.toDrawable
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
@@ -871,6 +872,8 @@ class HomeFragment : Fragment() {
            Homepage.privateModeIconTapped.record(mozilla.telemetry.glean.private.NoExtras())
        }

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

        consumeFrom(requireComponents.core.store) {
            toolbarView.updateTabCounter(it)
            showCollectionsPlaceholder(it)
+4 −0
Original line number Diff line number Diff line
@@ -353,6 +353,10 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
                } else {
                    inflater.inflate(R.menu.bookmarks_select_multi, menu)

                    menu.findItem(R.id.open_bookmarks_in_new_tabs_multi_select)?.apply {
                        isVisible = !requireContext().settings().shouldDisableNormalMode
                    }

                    menu.findItem(R.id.delete_bookmarks_multi_select).title =
                        SpannableString(getString(R.string.bookmark_menu_delete_button)).apply {
                            setTextColor(requireContext(), R.attr.textCritical)
Loading