Verified Commit f80ca9bc authored by Pier Angelo Vendrame's avatar Pier Angelo Vendrame 🎃
Browse files

fixup! Bug 42074: YEC 2023 Android

Revert "fixup! Bug 42074: YEC 2023 Android"

This reverts commit 19ec8acc.

Revert "Bug 42074: YEC 2023 Android"

This reverts commit 465ea2a8.
parent 3400c111
Loading
Loading
Loading
Loading
+2 −127
Original line number Diff line number Diff line
@@ -20,6 +20,8 @@ import android.widget.PopupWindow
import androidx.annotation.VisibleForTesting
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.content.ContextCompat
import androidx.core.view.children
import androidx.core.view.doOnLayout
import androidx.core.view.isGone
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
@@ -61,8 +63,6 @@ import mozilla.components.lib.state.ext.consumeFrom
import mozilla.components.service.glean.private.NoExtras
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
import mozilla.components.support.locale.LocaleManager
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.GleanMetrics.HomeScreen
import org.mozilla.fenix.GleanMetrics.PrivateBrowsingShortcutCfr
@@ -112,7 +112,6 @@ import org.mozilla.fenix.perf.MarkersFragmentLifecycleCallbacks
import org.mozilla.fenix.perf.runBlockingIncrement
import org.mozilla.fenix.search.toolbar.DefaultSearchSelectorController
import org.mozilla.fenix.search.toolbar.SearchSelectorMenu
import org.mozilla.fenix.settings.advanced.getSelectedLocale
import org.mozilla.fenix.tabstray.TabsTrayAccessPoint
import org.mozilla.fenix.tor.TorBootstrapFragmentDirections
import org.mozilla.fenix.tor.TorBootstrapStatus
@@ -121,8 +120,6 @@ import org.mozilla.fenix.utils.Settings.Companion.TOP_SITES_PROVIDER_MAX_THRESHO
import org.mozilla.fenix.utils.allowUndo
import org.mozilla.fenix.wallpapers.Wallpaper
import java.lang.ref.WeakReference
import java.text.NumberFormat
import java.util.Locale
import kotlin.math.min

@Suppress("TooManyFunctions", "LargeClass")
@@ -139,8 +136,6 @@ class HomeFragment : Fragment() {

    private val homeViewModel: HomeScreenViewModel by activityViewModels()

    private var hideYEC = false

    private val snackbarAnchorView: View?
        get() = when (requireContext().settings().toolbarPosition) {
            ToolbarPosition.BOTTOM -> binding.toolbarLayout
@@ -448,27 +443,6 @@ class HomeFragment : Fragment() {

        FxNimbus.features.homescreen.recordExposure()

        controlYECDisplay()

        binding.donateNowButton.setOnClickListener {
            val country = LocaleManager.getSelectedLocale(requireContext()).country
            var locale = LocaleManager.getSelectedLocale(requireContext()).language
            if (country != "") {
                locale = "${locale}-${country}"
            }
            val localeUrl = "https://www.torproject.org/donate/2023yec-${locale}-mobile"
            activity.openToBrowserAndLoad(
                searchTermOrURL = localeUrl,
                newTab = true,
                from = BrowserDirection.FromHome
            )
        }

        binding.yecClose.setOnClickListener {
            this.hideYEC = true
            controlYECDisplay()
        }

        // DO NOT MOVE ANYTHING BELOW THIS addMarker CALL!
        requireComponents.core.engine.profiler?.addMarker(
            MarkersFragmentLifecycleCallbacks.MARKER_NAME,
@@ -478,105 +452,6 @@ class HomeFragment : Fragment() {
        return binding.root
    }

    fun controlYECDisplay() {
        val yec23show = ((activity as? HomeActivity)?.themeManager?.isYECActive ?: false) && ! this.hideYEC
        val yec23matchingShow = ((activity as? HomeActivity)?.themeManager?.isYECPhase2Active ?: false) && ! this.hideYEC

        // hude onion pattern during EOY event
        binding.onionPatternImage.apply {
            visibility = if (!yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        // Hide tor browser header EOY event
        binding.exploreprivately.apply {
            visibility = if (!yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        // Hide EOY header text before EOY event
        binding.yecIntroText.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        // Hide EOY matching announcement before its time
        binding.yecMatchingText.apply {
            visibility = if (yec23matchingShow) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }
        binding.yecMatchingText.text = binding.yecMatchingText.text.replace(Regex("%s"), NumberFormat.getNumberInstance(Locale.getDefault()).format(75000))

        // Hide the EOY image before EOY event
        binding.yecIllustration.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        binding.yecPleaseDonateText.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }
        binding.yecFreeToUse.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        // Hide the EOY donate button before EOY event
        binding.donateNowButton.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        // Hide the EOY image before EOY event
        binding.yecPopup.apply {
            visibility = if (yec23show) {
                View.VISIBLE
            } else {
                View.GONE
            }
        }

        binding.exploreprivately.apply {
            visibility = if (yec23show) {
                View.GONE
            } else {
                View.VISIBLE
            }
        }

        binding.homeAppBar.apply {
            if (!yec23show){
                setExpanded(true, true)
            }
        }

    }

    override fun onConfigurationChanged(newConfig: Configuration) {
        super.onConfigurationChanged(newConfig)

+0 −12
Original line number Diff line number Diff line
@@ -23,23 +23,11 @@ import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
import java.util.Date

abstract class ThemeManager {
    // 1696118400000 // 2022 10 04 - testing
    // 1697414400000 // 2023 10 16
    private val yec2023LaunchDate = Date(1697414400000)
    // 1700614800000 // 2023 11 22
    private val yec2023Phase2 = Date(1700614800000)
    // 1704067200000 // 2024 01 01
    private val yec2023EndDate = Date(1704067200000)


    abstract var currentTheme: BrowsingMode

    val isYECActive get() = Date().after(yec2023LaunchDate) && Date().before(yec2023EndDate)
    val isYECPhase2Active get() = Date().after(yec2023Phase2) && Date().before(yec2023EndDate)

    /**
     * Returns the style resource corresponding to the [currentTheme].
     */
+0 −4
Original line number Diff line number Diff line
@@ -116,10 +116,6 @@ class TorBootstrapFragment : Fragment() {
        binding.toolbarLayout.apply {
            visibility = View.GONE
        }

        binding.yecPopup.apply {
            visibility = View.GONE
        }
    }

    // This function should be paired with adjustHomeFragmentView()
+0 −11
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- 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/.  -->

<!-- Used for rounding the corners of a button -->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#FFBD4F" />
    <corners android:radius="10dp" />
</shape>
+0 −5
Original line number Diff line number Diff line
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <solid android:color="#1F0333" />
    <corners android:radius="10dp" />
</shape>
Loading