clairehurst pushed to branch tor-browser-140.3.0esr-15.0-1 at The Tor Project / Applications / Tor Browser
Commits:
-
eae57191
by clairehurst at 2025-10-07T14:09:43-06:00
-
087dca19
by clairehurst at 2025-10-07T16:20:15-06:00
-
0e2ad060
by clairehurst at 2025-10-07T16:20:15-06:00
5 changed files:
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/CampaignCompose.kt
- + mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorCampaignViewModel.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorHomePage.kt
- mobile/android/fenix/app/src/main/java/org/mozilla/fenix/tor/TorHomePagePreview.kt
Changes:
... | ... | @@ -161,9 +161,9 @@ import org.mozilla.fenix.wallpapers.Wallpaper |
161 | 161 | import org.mozilla.fenix.GleanMetrics.TabStrip as TabStripMetrics
|
162 | 162 | |
163 | 163 | import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
164 | +import org.mozilla.fenix.tor.TorCampaignViewModel
|
|
164 | 165 | import org.mozilla.fenix.tor.TorHomePage
|
165 | 166 | import org.mozilla.fenix.tor.UrlQuickLoadViewModel
|
166 | -import org.mozilla.fenix.tor.shouldInitiallyShowPromo
|
|
167 | 167 | import java.util.Locale
|
168 | 168 | |
169 | 169 | @Suppress("TooManyFunctions", "LargeClass")
|
... | ... | @@ -179,6 +179,7 @@ class HomeFragment : Fragment(), UserInteractionHandler { |
179 | 179 | internal val binding get() = _binding!!
|
180 | 180 | private val snackbarBinding = ViewBoundFeatureWrapper<SnackbarBinding>()
|
181 | 181 | |
182 | + private val torCampaignViewModel: TorCampaignViewModel by activityViewModels()
|
|
182 | 183 | private val homeViewModel: HomeScreenViewModel by activityViewModels()
|
183 | 184 | private val urlQuickLoadViewModel: UrlQuickLoadViewModel by activityViewModels()
|
184 | 185 | |
... | ... | @@ -558,9 +559,7 @@ class HomeFragment : Fragment(), UserInteractionHandler { |
558 | 559 | listenForMicrosurveyMessage(requireContext())
|
559 | 560 | }
|
560 | 561 | |
561 | - binding.torHomepageView.setContent {
|
|
562 | - initComposeTorHomePageView()
|
|
563 | - }
|
|
562 | + initComposeTorHomePageView()
|
|
564 | 563 | |
565 | 564 | disableAppBarDragging()
|
566 | 565 | |
... | ... | @@ -978,7 +977,7 @@ class HomeFragment : Fragment(), UserInteractionHandler { |
978 | 977 | setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
|
979 | 978 | setContent {
|
980 | 979 | TorHomePage(
|
981 | - shouldInitiallyShowPromo(),
|
|
980 | + torCampaignViewModel.shouldInitiallyShowPromo,
|
|
982 | 981 | onClicked = {
|
983 | 982 | val baseUrl = "https://www.torproject.org/donate"
|
984 | 983 | val locale = Locale.getDefault().getLanguage()
|
... | ... | @@ -272,22 +272,3 @@ private fun DonateButton(onDonateButtonClicked: () -> Unit) { |
272 | 272 | )
|
273 | 273 | }
|
274 | 274 | } |
275 | - |
|
276 | - |
|
277 | - |
|
278 | -fun shouldInitiallyShowPromo(): Boolean {
|
|
279 | -// return true // uncomment to test
|
|
280 | - |
|
281 | - val dateFormat = SimpleDateFormat("yyyy-MM-dd-hh-zzz")
|
|
282 | - val startDate = dateFormat.parse("2025-10-14-15-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66
|
|
283 | - val endDate = dateFormat.parse("2026-01-02-00-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66#note_3257224
|
|
284 | - val currentDate = Date()
|
|
285 | - |
|
286 | - if (currentDate.before(startDate) || currentDate.after(endDate)) {
|
|
287 | - return false
|
|
288 | - }
|
|
289 | - if (BuildConfig.BUILD_TYPE == "release") {
|
|
290 | - return true
|
|
291 | - }
|
|
292 | - return false
|
|
293 | -} |
1 | +package org.mozilla.fenix.tor
|
|
2 | + |
|
3 | +import androidx.compose.runtime.MutableState
|
|
4 | +import androidx.compose.runtime.mutableStateOf
|
|
5 | +import androidx.lifecycle.ViewModel
|
|
6 | +import java.text.SimpleDateFormat
|
|
7 | +import java.util.Date
|
|
8 | +import kotlin.getValue
|
|
9 | +import org.mozilla.geckoview.BuildConfig
|
|
10 | + |
|
11 | +class TorCampaignViewModel : ViewModel() {
|
|
12 | + val shouldInitiallyShowPromo: MutableState<Boolean> by lazy {
|
|
13 | + mutableStateOf(shouldInitiallyShowPromo())
|
|
14 | + }
|
|
15 | + |
|
16 | + fun shouldInitiallyShowPromo(): Boolean {
|
|
17 | +// return true // uncomment to test
|
|
18 | + |
|
19 | + val dateFormat = SimpleDateFormat("yyyy-MM-dd-hh-zzz")
|
|
20 | + val startDate =
|
|
21 | + dateFormat.parse("2025-10-14-15-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66
|
|
22 | + val endDate =
|
|
23 | + dateFormat.parse("2026-01-02-00-UTC") // from https://gitlab.torproject.org/tpo/web/team/-/issues/66#note_3257224
|
|
24 | + val currentDate = Date()
|
|
25 | + |
|
26 | + if (currentDate.before(startDate) || currentDate.after(endDate)) {
|
|
27 | + return false
|
|
28 | + }
|
|
29 | + if (BuildConfig.BUILD_TYPE == "release") {
|
|
30 | + return true
|
|
31 | + }
|
|
32 | + return false
|
|
33 | + }
|
|
34 | +} |
... | ... | @@ -12,6 +12,7 @@ import androidx.compose.foundation.rememberScrollState |
12 | 12 | import androidx.compose.foundation.verticalScroll
|
13 | 13 | import androidx.compose.material.Text
|
14 | 14 | import androidx.compose.runtime.Composable
|
15 | +import androidx.compose.runtime.MutableState
|
|
15 | 16 | import androidx.compose.runtime.mutableStateOf
|
16 | 17 | import androidx.compose.runtime.saveable.rememberSaveable
|
17 | 18 | import androidx.compose.ui.Alignment
|
... | ... | @@ -36,19 +37,19 @@ import org.mozilla.fenix.R |
36 | 37 | @Composable
|
37 | 38 | @FlexibleWindowLightDarkPreview
|
38 | 39 | fun TorHomePage(
|
39 | - shouldInitiallyShowPromo: Boolean = false,
|
|
40 | + shouldInitiallyShowPromo: MutableState<Boolean> = mutableStateOf(false),
|
|
40 | 41 | onClicked: () -> Unit = {},
|
41 | 42 | toolBarAtTop: Boolean = true,
|
42 | 43 | ) {
|
43 | 44 | val shouldShowPromo = rememberSaveable {
|
44 | - mutableStateOf(shouldInitiallyShowPromo)
|
|
45 | + shouldInitiallyShowPromo
|
|
45 | 46 | }
|
46 | 47 | Column(
|
47 | 48 | modifier = Modifier
|
48 | 49 | .fillMaxSize()
|
49 | 50 | .padding(
|
50 | - top = if (toolBarAtTop) dimensionResource(R.dimen.tab_strip_height) else 0.dp,
|
|
51 | - bottom = if (!toolBarAtTop) dimensionResource(R.dimen.tab_strip_height) else 0.dp,
|
|
51 | + top = if (toolBarAtTop) dimensionResource(R.dimen.browser_navbar_height) else 0.dp,
|
|
52 | + bottom = if (!toolBarAtTop) dimensionResource(R.dimen.browser_navbar_height) else 0.dp,
|
|
52 | 53 | )
|
53 | 54 | .paint(
|
54 | 55 | BrushPainter(
|
1 | 1 | package org.mozilla.fenix.tor
|
2 | 2 | |
3 | +import android.annotation.SuppressLint
|
|
3 | 4 | import androidx.compose.foundation.layout.Box
|
4 | 5 | import androidx.compose.foundation.layout.fillMaxSize
|
5 | 6 | import androidx.compose.runtime.Composable
|
7 | +import androidx.compose.runtime.mutableStateOf
|
|
6 | 8 | import androidx.compose.ui.Alignment
|
7 | 9 | import androidx.compose.ui.Modifier
|
8 | 10 | import androidx.compose.ui.tooling.preview.PreviewParameter
|
... | ... | @@ -10,6 +12,7 @@ import androidx.compose.ui.tooling.preview.PreviewParameterProvider |
10 | 12 | import mozilla.components.compose.base.annotation.FlexibleWindowPreviewPortraitLandscapeEnglishArabicGerman
|
11 | 13 | import org.mozilla.fenix.home.ui.SearchBarPreview
|
12 | 14 | |
15 | +@SuppressLint("UnrememberedMutableState")
|
|
13 | 16 | @FlexibleWindowPreviewPortraitLandscapeEnglishArabicGerman
|
14 | 17 | @Composable
|
15 | 18 | /**
|
... | ... | @@ -26,7 +29,7 @@ private fun TorHomePagePreview( |
26 | 29 | SearchBarPreview() // unrestricted vertically so will follow contentAlignment
|
27 | 30 | TorHomePage(
|
28 | 31 | // restricted vertically so will not follow contentAlignment
|
29 | - shouldInitiallyShowPromo = booleanMatrix.first,
|
|
32 | + shouldInitiallyShowPromo = mutableStateOf(booleanMatrix.first),
|
|
30 | 33 | toolBarAtTop = toolbarAtTop,
|
31 | 34 | )
|
32 | 35 | }
|