GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit e8e73eba authored by Matthew Finkel's avatar Matthew Finkel

Bug 40016: Modify Default toolbar menu

parent 17cd0542
......@@ -177,25 +177,19 @@ 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 &&
!context.components.settings.shouldDisableNormalMode
val syncedTabsInTabsTray = context.components.settings
.syncedTabsInTabsTray
val menuItems = listOfNotNull(
downloadsItem,
historyItem,
// historyItem,
bookmarksItem,
if (syncedTabsInTabsTray) null else syncedTabs,
settings,
if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
deleteDataOnQuit,
BrowserMenuDivider(),
reportSiteIssuePlaceholder,
findInPage,
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 },
......
......@@ -100,7 +100,6 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder
import org.mozilla.fenix.home.sessioncontrol.viewholders.topsites.DefaultTopSitesView
import org.mozilla.fenix.onboarding.FenixOnboarding
import org.mozilla.fenix.settings.SupportUtils
import org.mozilla.fenix.settings.SupportUtils.SumoTopic.HELP
import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
import org.mozilla.fenix.theme.ThemeManager
import org.mozilla.fenix.utils.FragmentPreDrawManager
......@@ -782,7 +781,7 @@ class HomeFragment : Fragment() {
HomeMenu.Item.Help -> {
hideOnboardingIfNeeded()
(activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getSumoURLForTopic(context, HELP),
searchTermOrURL = SupportUtils.getTorHelpPageUrl(),
newTab = true,
from = BrowserDirection.FromHome
)
......
......@@ -246,10 +246,7 @@ class SettingsFragment : PreferenceFragmentCompat() {
}
resources.getString(R.string.pref_key_help) -> {
(activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = SupportUtils.getSumoURLForTopic(
requireContext(),
SupportUtils.SumoTopic.HELP
),
searchTermOrURL = SupportUtils.getTorHelpPageUrl(),
newTab = true,
from = BrowserDirection.FromSettings
)
......
......@@ -18,6 +18,7 @@ import java.io.UnsupportedEncodingException
import java.net.URLEncoder
import java.util.Locale
@Suppress("TooManyFunctions")
object SupportUtils {
const val RATE_APP_URL = "market://details?id=" + BuildConfig.APPLICATION_ID
const val POCKET_TRENDING_URL = "https://getpocket.com/fenix-top-articles"
......@@ -26,6 +27,8 @@ object SupportUtils {
const val FIREFOX_BETA_PLAY_STORE_URL = "market://details?id=org.mozilla.firefox_beta"
const val FIREFOX_NIGHTLY_PLAY_STORE_URL = "market://details?id=org.mozilla.fenix"
const val GOOGLE_URL = "https://www.google.com/"
const val TB_MANUAL_URL = "https://tb-manual.torproject.org/mobile-tor"
const val TOR_RELEASES = "https://www.torproject.org/releases/"
enum class SumoTopic(internal val topicStr: String) {
FENIX_MOVING("sync-delist"),
......@@ -77,13 +80,23 @@ object SupportUtils {
return "https://support.mozilla.org/kb/access-mozilla-services-firefox-account"
}
fun getTorHelpPageUrl(): String {
return TB_MANUAL_URL
}
fun getTorReleasePageUrl(): String {
return TOR_RELEASES
}
fun getMozillaPageUrl(page: MozillaPage, locale: Locale = Locale.getDefault()): String {
val path = page.path
val langTag = getLanguageTag(locale)
return "https://www.mozilla.org/$langTag/$path"
}
fun getWhatsNewUrl(context: Context) = getSumoURLForTopic(context, SumoTopic.WHATS_NEW)
fun getWhatsNewUrl(@Suppress("UNUSED_PARAMETER") context: Context): String {
return getTorReleasePageUrl()
}
fun createCustomTabIntent(context: Context, url: String): Intent = CustomTabsIntent.Builder()
.setInstantAppsEnabled(false)
......
......@@ -138,7 +138,7 @@ class AboutFragment : Fragment(), AboutPageListener {
AboutPageItem(
AboutItem.ExternalLink(
SUPPORT,
SupportUtils.getSumoURLForTopic(context, SupportUtils.SumoTopic.HELP)
SupportUtils.getTorHelpPageUrl()
), getString(R.string.about_support)
),
AboutPageItem(
......
......@@ -55,6 +55,18 @@ class SupportUtilsTest {
)
}
@Test
fun getTorPageUrl() {
assertEquals(
"https://tb-manual.torproject.org/mobile-tor",
SupportUtils.getTorHelpPageUrl()
)
assertEquals(
"https://www.torproject.org/releases/",
SupportUtils.getTorReleasePageUrl()
)
}
private fun mockContext(versionName: String): Context {
val context: Context = mockk()
val packageManager: PackageManager = mockk()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment