Commit 0f465a54 authored by clairehurst's avatar clairehurst 🌱 Committed by brizental
Browse files

fixup! TB 44031 [android]: 2025 YEC

parent dd61c67d
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -175,9 +175,9 @@ import org.mozilla.fenix.wallpapers.Wallpaper
import java.lang.ref.WeakReference

import org.mozilla.fenix.components.toolbar.ToolbarPosition
import org.mozilla.fenix.tor.TorCampaignViewModel
import org.mozilla.fenix.tor.TorHomePage
import org.mozilla.fenix.tor.UrlQuickLoadViewModel
import org.mozilla.fenix.tor.shouldInitiallyShowPromo
import java.util.Locale

@Suppress("TooManyFunctions", "LargeClass")
@@ -193,6 +193,7 @@ class HomeFragment : Fragment(), UserInteractionHandler {
    internal val binding get() = _binding!!
    private val snackbarBinding = ViewBoundFeatureWrapper<SnackbarBinding>()

    private val torCampaignViewModel: TorCampaignViewModel by activityViewModels()
    private val homeViewModel: HomeScreenViewModel by activityViewModels()
    private val urlQuickLoadViewModel: UrlQuickLoadViewModel by activityViewModels()

@@ -981,7 +982,7 @@ class HomeFragment : Fragment(), UserInteractionHandler {
            setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
            setContent {
                TorHomePage(
                    shouldInitiallyShowPromo(),
                    torCampaignViewModel.shouldInitiallyShowPromo,
                    onClicked = {
                        val baseUrl =  "https://www.torproject.org/donate"
                        val locale = Locale.getDefault().getLanguage()
+0 −19
Original line number Diff line number Diff line
@@ -272,22 +272,3 @@ private fun DonateButton(onDonateButtonClicked: () -> Unit) {
        )
    }
}



fun shouldInitiallyShowPromo(): Boolean {
//        return true // uncomment to test

    val dateFormat = SimpleDateFormat("yyyy-MM-dd-hh-zzz")
    val startDate = dateFormat.parse("2025-10-14-15-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66
    val endDate = dateFormat.parse("2026-01-02-00-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66#note_3257224
    val currentDate = Date()

    if (currentDate.before(startDate) || currentDate.after(endDate)) {
        return false
    }
    if (BuildConfig.BUILD_TYPE == "release") {
        return true
    }
    return false
}
+34 −0
Original line number Diff line number Diff line
package org.mozilla.fenix.tor

import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import java.text.SimpleDateFormat
import java.util.Date
import kotlin.getValue
import org.mozilla.geckoview.BuildConfig

class TorCampaignViewModel : ViewModel() {
    val shouldInitiallyShowPromo: MutableState<Boolean> by lazy {
        mutableStateOf(shouldInitiallyShowPromo())
    }

    fun shouldInitiallyShowPromo(): Boolean {
//        return true // uncomment to test

        val dateFormat = SimpleDateFormat("yyyy-MM-dd-hh-zzz")
        val startDate =
            dateFormat.parse("2025-10-14-15-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66
        val endDate =
            dateFormat.parse("2026-01-02-00-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66#note_3257224
        val currentDate = Date()

        if (currentDate.before(startDate) || currentDate.after(endDate)) {
            return false
        }
        if (BuildConfig.BUILD_TYPE == "release") {
            return true
        }
        return false
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -12,6 +12,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.ui.Alignment
@@ -36,12 +37,12 @@ import org.mozilla.fenix.R
@Composable
@FlexibleWindowLightDarkPreview
fun TorHomePage(
    shouldInitiallyShowPromo: Boolean = false,
    shouldInitiallyShowPromo: MutableState<Boolean> = mutableStateOf(false),
    onClicked: () -> Unit = {},
    toolBarAtTop: Boolean = true,
) {
    val shouldShowPromo = rememberSaveable {
        mutableStateOf(shouldInitiallyShowPromo)
        shouldInitiallyShowPromo
    }
    Column(
        modifier = Modifier