[tbb-commits] [Git][tpo/applications/fenix][tor-browser-102.2.1-12.0-1] yec22 home fragment, theming, and timegate toggle

Richard Pospesel (@richard) git at gitlab.torproject.org
Fri Dec 2 12:13:45 UTC 2022



Richard Pospesel pushed to branch tor-browser-102.2.1-12.0-1 at The Tor Project / Applications / fenix


Commits:
f9aea110 by Dan Ballard at 2022-12-02T12:09:59+00:00
yec22 home fragment, theming, and timegate toggle

- - - - -


11 changed files:

- app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
- app/src/main/java/org/mozilla/fenix/theme/ThemeManager.kt
- + app/src/main/res/drawable/ic_yec22_bg_combined_android_3x.png
- + app/src/main/res/drawable/tor_yec_donate_rounded_corners.xml
- + app/src/main/res/font/spacegrotesk_light.ttf
- + app/src/main/res/font/spacegrotesk_regular.ttf
- + app/src/main/res/font/spacegrotesk_semibold.ttf
- + app/src/main/res/font/spacemono_bold.ttf
- app/src/main/res/layout/fragment_home.xml
- app/src/main/res/values/colors.xml
- app/src/main/res/values/styles.xml


Changes:

=====================================
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
=====================================
@@ -10,11 +10,8 @@ import android.graphics.drawable.BitmapDrawable
 import android.graphics.drawable.ColorDrawable
 import android.os.Bundle
 import android.os.StrictMode
-import android.view.Gravity
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.view.ViewTreeObserver
+import android.util.Log
+import android.view.*
 import android.widget.Button
 import android.widget.LinearLayout
 import android.widget.PopupWindow
@@ -22,16 +19,10 @@ import androidx.annotation.VisibleForTesting
 import androidx.appcompat.content.res.AppCompatResources
 import androidx.constraintlayout.widget.ConstraintLayout
 import androidx.constraintlayout.widget.ConstraintSet
-import androidx.constraintlayout.widget.ConstraintSet.BOTTOM
-import androidx.constraintlayout.widget.ConstraintSet.PARENT_ID
-import androidx.constraintlayout.widget.ConstraintSet.TOP
+import androidx.constraintlayout.widget.ConstraintSet.*
 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.core.view.updateLayoutParams
+import androidx.core.view.*
 import androidx.fragment.app.Fragment
 import androidx.fragment.app.activityViewModels
 import androidx.lifecycle.Observer
@@ -66,15 +57,13 @@ import mozilla.components.service.glean.private.NoExtras
 import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
 import mozilla.components.support.ktx.android.content.res.resolveAttribute
 import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
+import mozilla.components.support.locale.LocaleManager
 import mozilla.components.ui.tabcounter.TabCounterMenu
-import org.mozilla.fenix.BuildConfig
-import org.mozilla.fenix.Config
+import org.mozilla.fenix.*
 import org.mozilla.fenix.GleanMetrics.Events
 import org.mozilla.fenix.GleanMetrics.HomeScreen
 import org.mozilla.fenix.GleanMetrics.StartOnHome
 import org.mozilla.fenix.GleanMetrics.Wallpapers
-import org.mozilla.fenix.HomeActivity
-import org.mozilla.fenix.R
 import org.mozilla.fenix.browser.BrowserAnimator.Companion.getToolbarNavOptions
 import org.mozilla.fenix.browser.browsingmode.BrowsingMode
 import org.mozilla.fenix.components.FenixSnackbar
@@ -84,12 +73,7 @@ import org.mozilla.fenix.components.appstate.AppAction
 import org.mozilla.fenix.components.toolbar.FenixTabCounterMenu
 import org.mozilla.fenix.components.toolbar.ToolbarPosition
 import org.mozilla.fenix.databinding.FragmentHomeBinding
-import org.mozilla.fenix.ext.components
-import org.mozilla.fenix.ext.hideToolbar
-import org.mozilla.fenix.ext.nav
-import org.mozilla.fenix.ext.requireComponents
-import org.mozilla.fenix.ext.runIfFragmentIsAttached
-import org.mozilla.fenix.ext.settings
+import org.mozilla.fenix.ext.*
 import org.mozilla.fenix.gleanplumb.DefaultMessageController
 import org.mozilla.fenix.gleanplumb.MessagingFeature
 import org.mozilla.fenix.home.mozonline.showPrivacyPopWindow
@@ -110,6 +94,7 @@ import org.mozilla.fenix.home.topsites.DefaultTopSitesView
 import org.mozilla.fenix.nimbus.FxNimbus
 import org.mozilla.fenix.onboarding.FenixOnboarding
 import org.mozilla.fenix.perf.MarkersFragmentLifecycleCallbacks
+import org.mozilla.fenix.settings.advanced.getSelectedLocale
 import org.mozilla.fenix.tabstray.TabsTrayAccessPoint
 import org.mozilla.fenix.tor.bootstrap.TorQuickStart
 import org.mozilla.fenix.utils.Settings.Companion.TOP_SITES_PROVIDER_MAX_THRESHOLD
@@ -117,6 +102,8 @@ import org.mozilla.fenix.utils.ToolbarPopupWindow
 import org.mozilla.fenix.utils.allowUndo
 import org.mozilla.fenix.wallpapers.WallpaperManager
 import java.lang.ref.WeakReference
+import java.util.*
+import kotlin.concurrent.schedule
 import kotlin.math.min
 
 @Suppress("TooManyFunctions", "LargeClass")
@@ -229,6 +216,13 @@ class HomeFragment : Fragment() {
             ?.replace(" *([.,。।]) *".toRegex(), "$1\n")
             ?.trim()
 
+        binding.yecPoweredbyprivacy.text = localBinding
+            .yecPoweredbyprivacy
+            .text
+            ?.replace(" *([.,。।]) *".toRegex(), "$1\n")
+            ?.trim()
+
+
         currentMode = CurrentMode(
             requireContext(),
             onboarding,
@@ -411,6 +405,20 @@ class HomeFragment : Fragment() {
         adjustHomeFragmentView(currentMode.getCurrentMode())
         showSessionControlView()
 
+        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/pbp-${locale}-mobile"
+            activity.openToBrowserAndLoad(
+                searchTermOrURL = localeUrl,
+                newTab = true,
+                from = BrowserDirection.FromHome
+            )
+        }
+
         // DO NOT MOVE ANYTHING BELOW THIS addMarker CALL!
         requireComponents.core.engine.profiler?.addMarker(
             MarkersFragmentLifecycleCallbacks.MARKER_NAME, profilerStartTime, "HomeFragment.onCreateView",
@@ -424,8 +432,34 @@ class HomeFragment : Fragment() {
 
         getMenuButton()?.dismissMenu()
         displayWallpaperIfEnabled()
+
+        //view.donationmatch.setOnClickListener {
+        //    activity.openToBrowserAndLoad(
+        //        searchTermOrURL = "https://blog.torproject.org/friends-of-tor-match-2020",
+        //        newTab = true,
+        //        from = BrowserDirection.FromHome
+        //    )
+        //}
+
+        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/pbp-${locale}-mobile"
+            (activity as HomeActivity).openToBrowserAndLoad(
+                searchTermOrURL = localeUrl,
+                newTab = true,
+                from = BrowserDirection.FromHome
+            )
+        }
     }
 
+    //private fun dismissTip(tip: Tip) {
+    //    sessionControlInteractor.onCloseTip(tip)
+    //}
+
     /**
      * Returns a [TopSitesConfig] which specifies how many top sites to display and whether or
      * not frequently visited sites should be displayed.
@@ -577,14 +611,97 @@ class HomeFragment : Fragment() {
                     }
                 }
             }
+            val yec22launched = (activity as? HomeActivity)?.themeManager?.isYECActive ?: false
+
             // Hide the onion pattern during Onboarding, too.
             binding.onionPatternImage.apply {
-                visibility = if (onboarding.userHasBeenOnboarded()) {
+                visibility = if (onboarding.userHasBeenOnboarded() && !yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
+            // Hide tor browser header during onboarding and EOY event
+            binding.exploreprivately.apply {
+                    visibility = if (onboarding.userHasBeenOnboarded() && !yec22launched) {
+                        View.VISIBLE
+                    } else {
+                        View.GONE
+                    }
+                }
+
+
+
+            // Hide EOY header text during onboarding and before event
+            binding.yecPoweredbyprivacy.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
+
+
+            // Hide the EOY image during Onboarding, and before event
+            binding.yecActivistImage.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
+            binding.yecResistanceImage.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+            binding.yecChangeImage.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+            binding.yecFreedomImage.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
+            // Hide the EOY donate button during Onboarding, and before event
+            binding.donateNowButton.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
+            // Hide EOY donation match text during onboarding and before event
+            binding.donationmatch.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
                     View.VISIBLE
                 } else {
                     View.GONE
                 }
             }
+
+            // Hide the EOY image during Onboarding, and before event
+            binding.yecImageLayout.apply {
+                visibility = if (onboarding.userHasBeenOnboarded() && yec22launched) {
+                    View.VISIBLE
+                } else {
+                    View.GONE
+                }
+            }
+
             binding.homeAppBar.apply {
                 visibility = View.VISIBLE
 
@@ -932,7 +1049,11 @@ class HomeFragment : Fragment() {
     override fun onResume() {
         super.onResume()
         if (browsingModeManager.mode == BrowsingMode.Private) {
-            activity?.window?.setBackgroundDrawableResource(R.drawable.private_home_background_gradient)
+            if ((activity as? HomeActivity)?.themeManager?.isYECActive ?: false) {
+                activity?.window?.setBackgroundDrawableResource(R.color.tor_yec_home_background)
+            } else {
+                activity?.window?.setBackgroundDrawableResource(R.drawable.private_home_background_gradient)
+            }
         }
 
         // fenix#40176: Ensure the Home fragment is rendered correctly when we resume.


=====================================
app/src/main/java/org/mozilla/fenix/theme/ThemeManager.kt
=====================================
@@ -23,18 +23,33 @@ import org.mozilla.fenix.HomeActivity
 import org.mozilla.fenix.R
 import org.mozilla.fenix.browser.browsingmode.BrowsingMode
 import org.mozilla.fenix.customtabs.ExternalAppBrowserActivity
+import org.mozilla.fenix.home.HomeFragment
+import java.util.*
 
 abstract class ThemeManager {
+    // 1663979387091 // 2022 9 21 - testing
+    // 1665619200000 // 2022 10 13
+    private val yec2022LaunchDate = Date(1665619200000)
+    // 1672531200000 // 2023 01 01
+    private val yec2022EndDate = Date(1672531200000)
 
     abstract var currentTheme: BrowsingMode
 
+    val isYECActive get() = Date().after(yec2022LaunchDate) && Date().before(yec2022EndDate)
+
     /**
      * Returns the style resource corresponding to the [currentTheme].
      */
     @get:StyleRes
     val currentThemeResource get() = when (currentTheme) {
         BrowsingMode.Normal -> R.style.NormalTheme
-        BrowsingMode.Private -> R.style.PrivateTheme
+        BrowsingMode.Private -> {
+            if (isYECActive) {
+                R.style.PrivateEOYTheme
+            } else {
+                R.style.PrivateTheme
+            }
+        }
     }
 
     /**


=====================================
app/src/main/res/drawable/ic_yec22_bg_combined_android_3x.png
=====================================
Binary files /dev/null and b/app/src/main/res/drawable/ic_yec22_bg_combined_android_3x.png differ


=====================================
app/src/main/res/drawable/tor_yec_donate_rounded_corners.xml
=====================================
@@ -0,0 +1,11 @@
+<?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="#C0FF00" />
+    <corners android:radius="10dp" />
+</shape>


=====================================
app/src/main/res/font/spacegrotesk_light.ttf
=====================================
Binary files /dev/null and b/app/src/main/res/font/spacegrotesk_light.ttf differ


=====================================
app/src/main/res/font/spacegrotesk_regular.ttf
=====================================
Binary files /dev/null and b/app/src/main/res/font/spacegrotesk_regular.ttf differ


=====================================
app/src/main/res/font/spacegrotesk_semibold.ttf
=====================================
Binary files /dev/null and b/app/src/main/res/font/spacegrotesk_semibold.ttf differ


=====================================
app/src/main/res/font/spacemono_bold.ttf
=====================================
Binary files /dev/null and b/app/src/main/res/font/spacemono_bold.ttf differ


=====================================
app/src/main/res/layout/fragment_home.xml
=====================================
@@ -102,6 +102,144 @@
             android:lineSpacingMultiplier="1.1"
             app:layout_scrollFlags="scroll" />
 
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_marginTop="50dp"
+            android:layout_weight="1"
+            android:orientation="vertical">
+
+            <TextView
+                android:id="@+id/yec_poweredbyprivacy"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:gravity="center"
+                android:layout_marginStart="35dp"
+                android:layout_marginEnd="35dp"
+                android:clickable="false"
+                android:focusable="false"
+                android:fontFamily="@font/spacemono_bold"
+                android:importantForAccessibility="no"
+                android:text="@string/yec2022_powered_by_privacy"
+                android:lineSpacingMultiplier="0.8"
+                android:textColor="#C0FF00"
+                android:textSize="28sp"
+                app:layout_scrollFlags="scroll" />
+
+            <RelativeLayout
+                android:id="@+id/yec_image_layout"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginTop="22dp"
+                android:layout_marginStart="35dp"
+                android:layout_marginEnd="35dp"
+                android:gravity="center"
+                android:orientation="vertical"  >
+
+                <ImageView
+                    android:id="@+id/yec_activist_image"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:scaleType="fitCenter"
+                    android:paddingTop="10dp"
+                    android:adjustViewBounds="true"
+                    app:layout_scrollFlags="scroll"
+                    app:srcCompat="@drawable/ic_yec22_bg_combined_android_3x"
+                    tools:ignore="ContentDescription" />
+
+                    <TextView
+                        android:id="@+id/yec_resistance_image"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_centerHorizontal="true"
+                        android:paddingStart="80dp"
+                        android:clickable="false"
+                        android:focusable="false"
+                        android:fontFamily="@font/spacegrotesk_semibold"
+                        android:importantForAccessibility="no"
+                        android:rotation="-2.25"
+                        android:text="@string/yec2022_resistance"
+                        android:textColor="#FF8AFF"
+                        android:textSize="33sp"
+                        app:layout_scrollFlags="scroll" />
+
+                    <TextView
+                        android:id="@+id/yec_change_image"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_centerHorizontal="true"
+                        android:paddingStart="80dp"
+                        android:layout_alignLeft="@+id/yec_resistance_image"
+                        android:layout_below="@+id/yec_resistance_image"
+                        android:layout_marginTop="-10dp"
+                        android:clickable="false"
+                        android:focusable="false"
+                        android:fontFamily="@font/spacegrotesk_light"
+                        android:importantForAccessibility="no"
+                        android:rotation="-2.25"
+                        android:text="@string/yec2022_change"
+                        android:textColor="#C0FF00"
+                        android:textSize="33sp"
+                        app:layout_scrollFlags="scroll" />
+
+                    <TextView
+                        android:id="@+id/yec_freedom_image"
+                        android:layout_width="wrap_content"
+                        android:layout_height="wrap_content"
+                        android:layout_centerHorizontal="true"
+                        android:paddingStart="80dp"
+                        android:layout_alignLeft="@+id/yec_resistance_image"
+                        android:layout_below="@+id/yec_change_image"
+                        android:layout_marginTop="-10dp"
+                        android:clickable="false"
+                        android:focusable="false"
+                        android:fontFamily="@font/spacegrotesk_semibold"
+                        android:importantForAccessibility="no"
+                        android:rotation="-2.25"
+                        android:text="@string/yec2022_freedom"
+                        android:textColor="#FF8AFF"
+                        android:textSize="33sp"
+                        app:layout_scrollFlags="scroll" />
+            </RelativeLayout>
+
+            <Button
+                android:id="@+id/donate_now_button"
+                style="@style/TorDonateYecButton"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginLeft="35dp"
+                android:layout_marginRight="35dp"
+                android:layout_marginTop="22dp"
+                android:background="@drawable/tor_yec_donate_rounded_corners"
+                android:text="@string/tor_onboarding_donate_button"
+                android:textAllCaps="false"
+                android:textColor="#000000"
+                android:textSize="18sp"
+                android:textStyle="bold"
+                android:visibility="visible"
+                tools:ignore="ButtonStyleXmlDetector" />
+
+            <TextView
+                android:id="@+id/donationmatch"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:paddingTop="22dp"
+                android:paddingStart="35dp"
+                android:paddingEnd="35dp"
+                android:clickable="false"
+                android:focusable="false"
+                android:fontFamily="@font/spacemono_bold"
+                android:importantForAccessibility="no"
+                android:lineSpacingMultiplier="1.1"
+                android:text="@string/yec2022_donation_matching"
+                android:textColor="#FAF5DF"
+                android:textSize="18sp"
+                android:gravity="center"
+                android:visibility="visible"
+                app:layout_scrollFlags="scroll" />
+
+
+        </LinearLayout>
     </com.google.android.material.appbar.AppBarLayout>
 
     <androidx.recyclerview.widget.RecyclerView


=====================================
app/src/main/res/values/colors.xml
=====================================
@@ -273,7 +273,7 @@
     <color name="sync_disconnected_background_private_theme">#5B5846</color>
     <color name="onboarding_illustration_deselected_private_theme">#99FBFBFE</color>
     <color name="prompt_login_edit_text_cursor_color_private_theme">@color/photonViolet50</color>
-
+    <color name="tor_yec_home_background">#0E0625</color>
     <!-- Normal theme colors for light mode -->
     <color name="accent_normal_theme">@color/photonInk20</color>
     <color name="accent_high_contrast_normal_theme">@color/photonInk20</color>


=====================================
app/src/main/res/values/styles.xml
=====================================
@@ -330,6 +330,11 @@
 
     <style name="PrivateTheme" parent="PrivateThemeBase" />
 
+    <style name="PrivateEOYTheme" parent="PrivateThemeBase" >
+        <item name="android:windowBackground">@color/tor_yec_home_background</item>
+        <item name="homeBackground">@color/tor_yec_home_background</item>
+    </style>
+
     <!-- Fade animation for theme switching -->
     <style name="WindowAnimationTransition">
         <item name="android:windowEnterAnimation">@anim/fade_in</item>
@@ -368,6 +373,21 @@
         <item name="android:textColor">#000000</item>
     </style>
 
+
+    <style name="TorDonateYecButton" parent="NeutralButton">
+        <item name="android:background">@drawable/tor_yec_donate_rounded_corners</item>
+        <item name="backgroundTint">#C0FF00</item>
+        <item name="android:textColor">#000000</item>
+        <item name="android:fontFamily">@font/spacemono_bold</item>
+        <item name="fontFamily">@font/spacemono_bold</item>
+    </style>
+
+    <style name="TorDonateYecButtonText" parent="Base.TextAppearance.MaterialComponents.Badge">
+
+        <item name="android:textStyle">bold</item>
+        <item name="android:textColor">#000000</item>
+    </style>
+
     <style name="DestructiveButton" parent="NeutralButton">
         <item name="iconTint">@color/fx_mobile_text_color_warning</item>
         <item name="android:textColor">@color/fx_mobile_text_color_warning</item>



View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/commit/f9aea110ce4f42a1a94e7b6edf38d86d9bdb6950

-- 
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/commit/f9aea110ce4f42a1a94e7b6edf38d86d9bdb6950
You're receiving this email because of your account on gitlab.torproject.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.torproject.org/pipermail/tbb-commits/attachments/20221202/aefac14b/attachment-0001.htm>


More information about the tbb-commits mailing list