Matthew Finkel pushed to branch tor-browser-91.2.0-10.5-2 at The Tor Project / Applications / fenix
Commits: 0dffacd8 by Matthew Finkel at 2021-09-30T18:16:20+00:00 Bug 40193: Add banner for VPN survey to Android homepage
- - - - -
11 changed files:
- app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt - app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt - app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt - app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt - + app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TorInfoBannerViewHolder.kt - app/src/main/java/org/mozilla/fenix/settings/SupportUtils.kt - + app/src/main/res/drawable/info_banner_padded_background.xml - + app/src/main/res/drawable/vpn_survey_icon.png - app/src/main/res/layout/fragment_home.xml - + app/src/main/res/layout/tor_info_banner.xml - app/src/main/res/values/colors.xml
Changes:
===================================== app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt ===================================== @@ -25,6 +25,7 @@ import org.mozilla.fenix.home.sessioncontrol.viewholders.CollectionViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.NoCollectionsMessageViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.PrivateBrowsingDescriptionViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.TorBootstrapPagerViewHolder +import org.mozilla.fenix.home.sessioncontrol.viewholders.TorInfoBannerViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.TabInCollectionViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.TopSitePagerViewHolder import org.mozilla.fenix.home.sessioncontrol.viewholders.onboarding.ExperimentDefaultBrowserCardViewHolder @@ -90,6 +91,7 @@ sealed class AdapterItem(@LayoutRes val viewType: Int) { }
object PrivateBrowsingDescription : AdapterItem(PrivateBrowsingDescriptionViewHolder.LAYOUT_ID) + object TorInfoBanner : AdapterItem(TorInfoBannerViewHolder.LAYOUT_ID) object NoCollectionsMessage : AdapterItem(NoCollectionsMessageViewHolder.LAYOUT_ID)
object TorBootstrap : AdapterItem(TorBootstrapPagerViewHolder.LAYOUT_ID) @@ -229,6 +231,10 @@ class SessionControlAdapter( view, interactor ) + TorInfoBannerViewHolder.LAYOUT_ID -> TorInfoBannerViewHolder( + view, + interactor + ) TorBootstrapPagerViewHolder.LAYOUT_ID -> TorBootstrapPagerViewHolder( view, components,
===================================== app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt ===================================== @@ -94,6 +94,11 @@ interface SessionControlController { */ fun handlePrivateBrowsingLearnMoreClicked()
+ /** + * @see [TabSessionInteractor.onTorInfoBannerLaunchClicked] + */ + fun handleTorInfoBannerLaunchClicked() + /** * @see [TopSiteInteractor.onRenameTopSiteClicked] */ @@ -647,4 +652,12 @@ class DefaultSessionControlController( override fun handleTorNetworkSettingsClicked() { openTorNetworkSettings() } + + override fun handleTorInfoBannerLaunchClicked() { + activity.openToBrowserAndLoad( + searchTermOrURL = SupportUtils.TOR_INFO_BANNER_URL, + newTab = true, + from = BrowserDirection.FromHome + ) + } }
===================================== app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt ===================================== @@ -23,6 +23,12 @@ interface TabSessionInteractor { * "Common myths about private browsing" link in private mode. */ fun onPrivateBrowsingLearnMoreClicked() + + /** + * Shows the Info Banner web page in a new tab. Called when a user clicks on the + * "Learn More" button. + */ + fun onTorInfoBannerLaunchClicked() }
/** @@ -412,4 +418,8 @@ class SessionControlInteractor( override fun onTorBootstrapNetworkSettingsClicked() { controller.handleTorNetworkSettingsClicked() } + + override fun onTorInfoBannerLaunchClicked() { + controller.handleTorInfoBannerLaunchClicked() + } }
===================================== app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt ===================================== @@ -92,7 +92,7 @@ private fun showCollections( } }
-private fun privateModeAdapterItems() = listOf(AdapterItem.PrivateBrowsingDescription) +private fun privateModeAdapterItems() = listOf(AdapterItem.TorInfoBanner)
private fun bootstrapAdapterItems() = listOf(AdapterItem.TorBootstrap)
===================================== app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/TorInfoBannerViewHolder.kt ===================================== @@ -0,0 +1,33 @@ +/* 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/. */ + +package org.mozilla.fenix.home.sessioncontrol.viewholders + +import android.graphics.Typeface +import android.text.SpannableString +import android.text.Spanned +import android.text.style.StyleSpan +import android.view.View +import androidx.recyclerview.widget.RecyclerView +import kotlinx.android.synthetic.main.tor_info_banner.view.* +import org.mozilla.fenix.R +import org.mozilla.fenix.home.sessioncontrol.TabSessionInteractor + +class TorInfoBannerViewHolder( + view: View, + private val interactor: TabSessionInteractor +) : RecyclerView.ViewHolder(view) { + + init { + with(view.info_banner_launch_button) { + setOnClickListener { + interactor.onTorInfoBannerLaunchClicked() + } + } + } + + companion object { + const val LAYOUT_ID = R.layout.tor_info_banner + } +}
===================================== app/src/main/java/org/mozilla/fenix/settings/SupportUtils.kt ===================================== @@ -40,6 +40,7 @@ object SupportUtils { const val DONATE_URL = "https://donate.torproject.org/" const val TB_MANUAL_URL = "https://tb-manual.torproject.org/mobile-tor" const val TOR_RELEASES = "https://www.torproject.org/releases/" + const val TOR_INFO_BANNER_URL = "http://eh5esdnd6fkbkapfc6nuyvkjgbtnzq2is72lmpwbdbxepd2z7zbgzsqd.onion/index...."
enum class SumoTopic(internal val topicStr: String) { FENIX_MOVING("sync-delist"),
===================================== app/src/main/res/drawable/info_banner_padded_background.xml ===================================== @@ -0,0 +1,13 @@ +<?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/. --> +<ripple xmlns:android="http://schemas.android.com/apk/res/android" + android:color="@color/info_banner_padded_background_color"> + <item + android:bottom="6dp" + android:top="6dp"> + <shape android:shape="rectangle"> + <corners android:radius="4dp" /> + </shape> + </item> +</ripple>
===================================== app/src/main/res/drawable/vpn_survey_icon.png ===================================== Binary files /dev/null and b/app/src/main/res/drawable/vpn_survey_icon.png differ
===================================== app/src/main/res/layout/fragment_home.xml ===================================== @@ -94,7 +94,8 @@ android:textColor="#DEFFFFFF" android:textSize="40sp" android:lineSpacingMultiplier="1.1" - app:layout_scrollFlags="scroll" /> + app:layout_scrollFlags="scroll" + android:visibility="gone" />
</com.google.android.material.appbar.AppBarLayout>
===================================== app/src/main/res/layout/tor_info_banner.xml ===================================== @@ -0,0 +1,79 @@ +<?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/. --> +<androidx.constraintlayout.widget.ConstraintLayout + xmlns:android="http://schemas.android.com/apk/res/android" + xmlns:app="http://schemas.android.com/apk/res-auto" + android:id="@+id/info_banner_wrapper" + style="@style/OnboardingCardLightWithPadding" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:clipChildren="false" + android:clipToPadding="false"> + + <LinearLayout + android:id="@+id/info_banner_header_wrapper" + android:layout_width="match_parent" + android:layout_height="wrap_content" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" + android:importantForAccessibility="no"> + + <ImageView + android:id="@+id/tor_info_banner_icon" + android:layout_width="wrap_content" + android:layout_height="32dp" + android:layout_marginEnd="10dp" + android:adjustViewBounds="true" + android:clickable="false" + android:focusable="false" + android:importantForAccessibility="no" + app:srcCompat="@drawable/vpn_survey_icon"/> + + <TextView + android:id="@+id/info_banner_header" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:lineSpacingExtra="6dp" + android:paddingHorizontal="4dp" + android:paddingTop="4dp" + android:scrollHorizontally="false" + android:textAlignment="viewStart" + android:textColor="?primaryText" + android:textSize="20sp" + android:text="Do you use a VPN?" /> + </LinearLayout> + + <TextView + android:id="@+id/info_banner_description" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:ellipsize="none" + android:lineSpacingExtra="6dp" + android:paddingHorizontal="4dp" + android:paddingTop="4dp" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/info_banner_header_wrapper" + android:scrollHorizontally="false" + android:textAlignment="viewStart" + android:textColor="?primaryText" + android:textSize="16sp" + android:text="We’d like to learn more about how and why our users use VPNs. Complete this short ten-minute survey to tell us about your experience:" /> + + <Button + style="@style/PositiveButton" + android:id="@+id/info_banner_launch_button" + android:text="Learn More" + android:layout_marginTop="16dp" + android:textSize="18dp" + android:textColor="@android:color/black" + android:background="@drawable/info_banner_padded_background" + android:fontFamily="Roboto-Medium" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/info_banner_description" /> + +</androidx.constraintlayout.widget.ConstraintLayout>
===================================== app/src/main/res/values/colors.xml ===================================== @@ -424,4 +424,7 @@
<!-- Toolbar menu icon colors --> <color name="toolbar_menu_transparent">@android:color/transparent</color> + + <!-- Tor --> + <color name="info_banner_padded_background_color">#A76FFA</color> </resources>
View it on GitLab: https://gitlab.torproject.org/tpo/applications/fenix/-/commit/0dffacd86eee81...
tor-commits@lists.torproject.org