Unverified Commit 36953a48 authored by Alex Catarineu's avatar Alex Catarineu Committed by boklm
Browse files

Modify UI/UX

Bug 40015: Modify Home menu

Bug 40016: Hide unwanted Settings

Bug 40016: Modify Default toolbar menu

Bug 40016: Add Donate settings button

Bug 40016: Move Allow Screenshots under Advanced

Bug 40016: Don't install WebCompat webext

Bug 40016: Don't onboard Search Suggestions

Bug 40094: Do not use MasterPasswordTipProvider in HomeFragment

Bug 40095: Hide "Sign in to sync" in bookmarks

Bug 40031: Hide Mozilla-specific items on About page

Bug 40032: Set usesCleartextTraffic as false

Bug 40063: Do not sort search engines alphabetically

Bug 34378: Port external helper app prompting

With the corresponding android-components patch, this allows all `startActivity`
that may open external apps to be replaced by `TorUtils.startActivityPrompt`.

Bug 34403: Disable Normal mode by default

Bug 40087: Implement a switch for english locale spoofing

Bug 40144: Hide Download Manager

Bug 40141: Hide EME site permission
parent cf7ca790
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
        android:roundIcon="@mipmap/ic_launcher"
        android:supportsRtl="true"
        android:theme="@style/NormalTheme"
        android:usesCleartextTraffic="true"
        android:usesCleartextTraffic="false"
        tools:ignore="UnusedAttribute">

        <!--
+53 −2
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

package org.mozilla.fenix

import android.app.PendingIntent
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
@@ -49,6 +50,8 @@ import mozilla.components.concept.engine.EngineSession
import mozilla.components.concept.engine.EngineView
import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.feature.app.links.RedirectDialogFragment
import mozilla.components.feature.app.links.SimpleRedirectDialogFragment
import mozilla.components.feature.contextmenu.DefaultSelectionActionDelegate
import mozilla.components.feature.privatemode.notification.PrivateNotificationFeature
import mozilla.components.feature.search.BrowserStoreSearchAdapter
@@ -64,6 +67,7 @@ import mozilla.components.support.ktx.kotlin.isUrl
import mozilla.components.support.ktx.kotlin.toNormalizedUrl
import mozilla.components.support.locale.LocaleAwareAppCompatActivity
import mozilla.components.support.utils.SafeIntent
import mozilla.components.support.utils.TorUtils
import mozilla.components.support.utils.toSafeIntent
import mozilla.components.support.webextensions.WebExtensionPopupFeature
import org.mozilla.fenix.GleanMetrics.Metrics
@@ -177,6 +181,7 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    private val startupPathProvider = StartupPathProvider()
    private lateinit var startupTypeTelemetry: StartupTypeTelemetry

    private var dialog: RedirectDialogFragment? = null
    final override fun onCreate(savedInstanceState: Bundle?): Unit = PerfStartup.homeActivityOnCreate.measureNoInline {
        // DO NOT MOVE ANYTHING ABOVE THIS addMarker CALL.
        components.core.engine.profiler?.addMarker("Activity.onCreate", "HomeActivity")
@@ -478,6 +483,26 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
        super.recreate()
    }

    // Copied from mozac AppLinksFeature.kt
    internal fun getOrCreateDialog(): RedirectDialogFragment {
        val existingDialog = dialog
        if (existingDialog != null) {
            return existingDialog
        }

        SimpleRedirectDialogFragment.newInstance().also {
            dialog = it
            return it
        }
    }
    private fun isAlreadyADialogCreated(): Boolean {
        return findPreviousDialogFragment() != null
    }

    private fun findPreviousDialogFragment(): RedirectDialogFragment? {
        return supportFragmentManager.findFragmentByTag(RedirectDialogFragment.FRAGMENT_TAG) as? RedirectDialogFragment
    }

    /**
     * Handles intents received when the activity is open.
     */
@@ -490,6 +515,26 @@ open class HomeActivity : LocaleAwareAppCompatActivity(), NavHostActivity {
    }

    open fun handleNewIntent(intent: Intent) {
        val startIntent = intent.getParcelableExtra<PendingIntent>(TorUtils.TORBROWSER_START_ACTIVITY_PROMPT)
        if (startIntent != null) {
            if (startIntent.creatorPackage == applicationContext.packageName) {
                val dialog = getOrCreateDialog()
                dialog.onConfirmRedirect = {
                    @Suppress("EmptyCatchBlock")
                    try {
                        startIntent.send()
                    } catch (error: PendingIntent.CanceledException) {
                    }
                }
                dialog.onCancelRedirect = {}

                if (!isAlreadyADialogCreated()) {
                    dialog.showNow(supportFragmentManager, RedirectDialogFragment.FRAGMENT_TAG)
                }
            }
            return
        }

        // Diagnostic breadcrumb for "Display already aquired" crash:
        // https://github.com/mozilla-mobile/android-components/issues/7960
        breadcrumb(
@@ -693,11 +738,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
        }
    }

    /**
+9 −1
Original line number Diff line number Diff line
@@ -447,7 +447,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
            shouldForwardToThirdParties = {
                PreferenceManager.getDefaultSharedPreferences(context).getBoolean(
                    context.getPreferenceKey(R.string.pref_key_external_download_manager), false
                )
                ) && false
            },
            promptsStyling = DownloadsFeature.PromptsStyling(
                gravity = Gravity.BOTTOM,
@@ -944,6 +944,14 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Activit
        hideToolbar()

        components.core.store.state.findTabOrCustomTabOrSelectedTab(customTabSessionId)?.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.content.private && requireContext().settings().shouldDisableNormalMode) {
                findNavController().nav(
                    R.id.browserFragment,
                    BrowserFragmentDirections.actionGlobalHomeFragment()
                )
            }
            updateThemeForSession(it)
        }
    }
+4 −3
Original line number Diff line number Diff line
@@ -111,7 +111,8 @@ class Core(
            clearColor = ContextCompat.getColor(
                context,
                R.color.foundation_normal_theme
            )
            ),
            spoofEnglish = context.settings().spoofEnglish
        )

        GeckoEngine(
@@ -123,7 +124,6 @@ class Core(
                trackingProtectionPolicyFactory.createTrackingProtectionPolicy()
            )
        ).also {
            WebCompatFeature.install(it)

            /**
             * There are some issues around localization to be resolved, as well as questions around
@@ -131,7 +131,8 @@ class Core(
             * disabled in Fenix Release builds for now.
             * This is consistent with both Fennec and Firefox Desktop.
             */
            if (Config.channel.isNightlyOrDebug || Config.channel.isBeta) {
            if (false && (Config.channel.isNightlyOrDebug || Config.channel.isBeta)) {
                WebCompatFeature.install(it)
                WebCompatReporterFeature.install(it, "fenix")
            }
        }
+94 −96
Original line number Diff line number Diff line
@@ -207,20 +207,20 @@ open class DefaultToolbarMenu(
    } ?: false
    // End of predicates //

    val installToHomescreen = BrowserMenuHighlightableItem(
        label = context.getString(R.string.browser_menu_install_on_homescreen),
        startImageResource = R.drawable.ic_add_to_homescreen,
        iconTintColorResource = primaryTextColor(),
        highlight = BrowserMenuHighlight.LowPriority(
            label = context.getString(R.string.browser_menu_install_on_homescreen),
            notificationTint = getColor(context, R.color.whats_new_notification_color)
        ),
        isHighlighted = {
            !context.settings().installPwaOpened
        }
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.InstallPwaToHomeScreen)
    }
    //val installToHomescreen = BrowserMenuHighlightableItem(
    //    label = context.getString(R.string.browser_menu_install_on_homescreen),
    //    startImageResource = R.drawable.ic_add_to_homescreen,
    //    iconTintColorResource = primaryTextColor(),
    //    highlight = BrowserMenuHighlight.LowPriority(
    //        label = context.getString(R.string.browser_menu_install_on_homescreen),
    //        notificationTint = getColor(context, R.color.whats_new_notification_color)
    //    ),
    //    isHighlighted = {
    //        !context.settings().installPwaOpened
    //    }
    //) {
    //    onItemTapped.invoke(ToolbarMenu.Item.InstallPwaToHomeScreen)
    //}

    private val oldCoreMenuItems by lazy {
        val settings = BrowserMenuHighlightableItem(
@@ -260,21 +260,21 @@ open class DefaultToolbarMenu(
            onItemTapped.invoke(ToolbarMenu.Item.AddToTopSites)
        }

        val addToHomescreen = BrowserMenuImageText(
            label = context.getString(R.string.browser_menu_add_to_homescreen),
            imageResource = R.drawable.ic_add_to_homescreen,
            iconTintColorResource = primaryTextColor()
        ) {
            onItemTapped.invoke(ToolbarMenu.Item.AddToHomeScreen)
        }
        //val addToHomescreen = BrowserMenuImageText(
        //    label = context.getString(R.string.browser_menu_add_to_homescreen),
        //    imageResource = R.drawable.ic_add_to_homescreen,
        //    iconTintColorResource = primaryTextColor()
        //) {
        //    onItemTapped.invoke(ToolbarMenu.Item.AddToHomeScreen)
        //}

        val syncedTabs = BrowserMenuImageText(
            label = context.getString(R.string.synced_tabs),
            imageResource = R.drawable.ic_synced_tabs,
            iconTintColorResource = primaryTextColor()
        ) {
            onItemTapped.invoke(ToolbarMenu.Item.SyncedTabs)
        }
        //val syncedTabs = BrowserMenuImageText(
        //    label = context.getString(R.string.synced_tabs),
        //    imageResource = R.drawable.ic_synced_tabs,
        //    iconTintColorResource = primaryTextColor()
        //) {
        //    onItemTapped.invoke(ToolbarMenu.Item.SyncedTabs)
        //}

        val findInPage = BrowserMenuImageText(
            label = context.getString(R.string.browser_menu_find_in_page),
@@ -284,9 +284,9 @@ open class DefaultToolbarMenu(
            onItemTapped.invoke(ToolbarMenu.Item.FindInPage)
        }

        val reportSiteIssuePlaceholder = WebExtensionPlaceholderMenuItem(
            id = WebCompatReporterFeature.WEBCOMPAT_REPORTER_EXTENSION_ID
        )
        //val reportSiteIssuePlaceholder = WebExtensionPlaceholderMenuItem(
        //    id = WebCompatReporterFeature.WEBCOMPAT_REPORTER_EXTENSION_ID
        //)

        val saveToCollection = BrowserMenuImageText(
            label = context.getString(R.string.browser_menu_save_to_collection_2),
@@ -325,13 +325,13 @@ open class DefaultToolbarMenu(
            onItemTapped.invoke(ToolbarMenu.Item.OpenInApp)
        }

        val historyItem = BrowserMenuImageText(
            context.getString(R.string.library_history),
            R.drawable.ic_history,
            primaryTextColor()
        ) {
            onItemTapped.invoke(ToolbarMenu.Item.History)
        }
        //val historyItem = BrowserMenuImageText(
        //    context.getString(R.string.library_history),
        //    R.drawable.ic_history,
        //    primaryTextColor()
        //) {
        //    onItemTapped.invoke(ToolbarMenu.Item.History)
        //}

        val bookmarksItem = BrowserMenuImageText(
            context.getString(R.string.library_bookmarks),
@@ -352,25 +352,23 @@ open class DefaultToolbarMenu(
        // Predicates that are called once, during screen init
        val shouldShowSaveToCollection = (context.asActivity() as? HomeActivity)
            ?.browsingModeManager?.mode == BrowsingMode.Normal
        val shouldDeleteDataOnQuit = context.components.settings
            .shouldDeleteBrowsingDataOnQuit

        val menuItems = listOfNotNull(
            downloadsItem,
            historyItem,
            // historyItem,
            bookmarksItem,
            syncedTabs,
            // syncedTabs,
            settings,
            if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
            deleteDataOnQuit,
            BrowserMenuDivider(),
            reportSiteIssuePlaceholder,
            //reportSiteIssuePlaceholder,
            findInPage,
            getSetDefaultBrowserItem()?.let { BrowserMenuDivider() },
            getSetDefaultBrowserItem(),
            getSetDefaultBrowserItem()?.let { BrowserMenuDivider() },
            addToTopSites,
            addToHomescreen.apply { visible = ::canAddToHomescreen },
            installToHomescreen.apply { visible = ::canInstall },
            // addToHomescreen.apply { visible = ::canAddToHomescreen },
            // installToHomescreen.apply { visible = ::canInstall },
            if (shouldShowSaveToCollection) saveToCollection else null,
            desktopMode,
            openInApp.apply { visible = ::shouldShowOpenInApp },
@@ -394,13 +392,13 @@ open class DefaultToolbarMenu(
        onItemTapped.invoke(ToolbarMenu.Item.NewTab)
    }

    val historyItem = BrowserMenuImageText(
        context.getString(R.string.library_history),
        R.drawable.ic_history,
        primaryTextColor()
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.History)
    }
    //val historyItem = BrowserMenuImageText(
    //    context.getString(R.string.library_history),
    //    R.drawable.ic_history,
    //    primaryTextColor()
    //) {
    //    onItemTapped.invoke(ToolbarMenu.Item.History)
    //}

    val downloadsItem = BrowserMenuImageText(
        context.getString(R.string.library_downloads),
@@ -453,18 +451,18 @@ open class DefaultToolbarMenu(
        onItemTapped.invoke(ToolbarMenu.Item.OpenInApp)
    }

    val reportSiteIssuePlaceholder = WebExtensionPlaceholderMenuItem(
        id = WebCompatReporterFeature.WEBCOMPAT_REPORTER_EXTENSION_ID
    )
    //val reportSiteIssuePlaceholder = WebExtensionPlaceholderMenuItem(
    //    id = WebCompatReporterFeature.WEBCOMPAT_REPORTER_EXTENSION_ID
    //)

    val addToHomeScreenItem = BrowserMenuImageText(
        label = context.getString(R.string.browser_menu_add_to_homescreen),
        imageResource = R.drawable.ic_add_to_homescreen,
        iconTintColorResource = primaryTextColor(),
        isCollapsingMenuLimit = true
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.AddToHomeScreen)
    }
    //val addToHomeScreenItem = BrowserMenuImageText(
    //    label = context.getString(R.string.browser_menu_add_to_homescreen),
    //    imageResource = R.drawable.ic_add_to_homescreen,
    //    iconTintColorResource = primaryTextColor(),
    //    isCollapsingMenuLimit = true
    //) {
    //    onItemTapped.invoke(ToolbarMenu.Item.AddToHomeScreen)
    //}

    val addToTopSitesItem = BrowserMenuImageText(
        label = context.getString(R.string.browser_menu_add_to_top_sites),
@@ -526,32 +524,32 @@ open class DefaultToolbarMenu(
        onItemTapped.invoke(ToolbarMenu.Item.Quit)
    }

    val syncedTabsItem = BrowserMenuImageText(
        context.getString(R.string.synced_tabs),
        R.drawable.ic_synced_tabs,
        primaryTextColor()
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.SyncedTabs)
    }

    private fun getSyncItemTitle(): String {
        val authenticatedAccount = accountManager.authenticatedAccount
        val email = accountManager.accountProfileEmail

        return if (authenticatedAccount && !email.isNullOrEmpty()) {
            email
        } else {
            context.getString(R.string.sync_menu_sign_in)
        }
    }

    val syncMenuItem = BrowserMenuImageText(
        getSyncItemTitle(),
        R.drawable.ic_signed_out,
        primaryTextColor()
    ) {
        onItemTapped.invoke(ToolbarMenu.Item.SyncAccount(accountManager.signedInToFxa()))
    }
    // val syncedTabsItem = BrowserMenuImageText(
    //     context.getString(R.string.synced_tabs),
    //     R.drawable.ic_synced_tabs,
    //     primaryTextColor()
    // ) {
    //     onItemTapped.invoke(ToolbarMenu.Item.SyncedTabs)
    // }

    // private fun getSyncItemTitle(): String {
    //     val authenticatedAccount = accountManager.authenticatedAccount
    //     val email = accountManager.accountProfileEmail

    //     return if (authenticatedAccount && !email.isNullOrEmpty()) {
    //         email
    //     } else {
    //         context.getString(R.string.sync_menu_sign_in)
    //     }
    // }

    // val syncMenuItem = BrowserMenuImageText(
    //     getSyncItemTitle(),
    //     R.drawable.ic_signed_out,
    //     primaryTextColor()
    // ) {
    //     onItemTapped.invoke(ToolbarMenu.Item.SyncAccount(accountManager.signedInToFxa()))
    // }

    @VisibleForTesting(otherwise = PRIVATE)
    val newCoreMenuItems by lazy {
@@ -561,10 +559,10 @@ open class DefaultToolbarMenu(
                newTabItem,
                BrowserMenuDivider(),
                bookmarksItem,
                historyItem,
                //historyItem,
                downloadsItem,
                extensionsItem,
                if (tabsTrayRewrite) syncMenuItem else syncedTabsItem,
                //if (tabsTrayRewrite) syncMenuItem else syncedTabsItem,
                BrowserMenuDivider(),
                getSetDefaultBrowserItem(),
                getSetDefaultBrowserItem()?.let { BrowserMenuDivider() },
@@ -572,10 +570,10 @@ open class DefaultToolbarMenu(
                desktopSiteItem,
                customizeReaderView.apply { visible = ::shouldShowReaderViewCustomization },
                openInApp.apply { visible = ::shouldShowOpenInApp },
                reportSiteIssuePlaceholder,
                //reportSiteIssuePlaceholder,
                BrowserMenuDivider(),
                addToHomeScreenItem.apply { visible = ::canAddToHomescreen },
                installToHomescreen.apply { visible = ::canInstall },
                //addToHomeScreenItem.apply { visible = ::canAddToHomescreen },
                //installToHomescreen.apply { visible = ::canInstall },
                addToTopSitesItem,
                saveToCollectionItem,
                BrowserMenuDivider(),
Loading