Commit 372b1e7f authored by mcarare's avatar mcarare Committed by Jeff Boek
Browse files

For #6980: Update Private browsing card.

Added test to description.
Added link to settings.
Updated unit tests.
parent 127169f5
......@@ -206,7 +206,8 @@ class HomeFragment : Fragment() {
invokePendingDeleteJobs = ::invokePendingDeleteJobs,
registerCollectionStorageObserver = ::registerCollectionStorageObserver,
scrollToTheTop = ::scrollToTheTop,
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt,
openSettingsScreen = :: openSettingsScreen
)
)
updateLayout(view)
......@@ -548,6 +549,11 @@ class HomeFragment : Fragment() {
nav(R.id.homeFragment, directions)
}
private fun openSettingsScreen() {
val directions = HomeFragmentDirections.actionHomeFragmentToPrivateBrowsingFragment()
nav(R.id.homeFragment, directions)
}
private fun createHomeMenu(context: Context): HomeMenu {
return HomeMenu(context) {
when (it) {
......
......@@ -170,7 +170,7 @@ class SessionControlAdapter(
OnboardingManualSignInViewHolder.LAYOUT_ID -> OnboardingManualSignInViewHolder(view)
OnboardingThemePickerViewHolder.LAYOUT_ID -> OnboardingThemePickerViewHolder(view)
OnboardingTrackingProtectionViewHolder.LAYOUT_ID -> OnboardingTrackingProtectionViewHolder(view)
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view)
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view, interactor)
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view)
......
......@@ -139,6 +139,11 @@ interface SessionControlController {
*/
fun handleStartBrowsingClicked()
/**
* @see [OnboardingInteractor.onOpenSettingsClicked]
*/
fun handleOpenSettingsClicked()
/**
* @see [CollectionInteractor.onToggleCollectionExpanded]
*/
......@@ -159,7 +164,8 @@ class DefaultSessionControlController(
private val invokePendingDeleteJobs: () -> Unit,
private val registerCollectionStorageObserver: () -> Unit,
private val scrollToTheTop: () -> Unit,
private val showDeleteCollectionPrompt: (tabCollection: TabCollection) -> Unit
private val showDeleteCollectionPrompt: (tabCollection: TabCollection) -> Unit,
private val openSettingsScreen: () -> Unit
) : SessionControlController {
private val metrics: MetricController
get() = activity.components.analytics.metrics
......@@ -358,6 +364,10 @@ class DefaultSessionControlController(
hideOnboarding()
}
override fun handleOpenSettingsClicked() {
openSettingsScreen()
}
override fun handleToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
store.dispatch(HomeFragmentAction.CollectionExpanded(collection, expand))
}
......
......@@ -87,6 +87,11 @@ interface OnboardingInteractor {
* Hides the onboarding and navigates to Search. Called when a user clicks on the "Start Browsing" button.
*/
fun onStartBrowsingClicked()
/**
* Hides the onboarding and navigates to Settings. Called when a user clicks on the "Open settings" button.
*/
fun onOpenSettingsClicked()
}
/**
......@@ -262,6 +267,10 @@ class SessionControlInteractor(
controller.handleStartBrowsingClicked()
}
override fun onOpenSettingsClicked() {
controller.handleOpenSettingsClicked()
}
override fun onToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
controller.handleToggleCollectionExpanded(collection, expand)
}
......
......@@ -110,8 +110,8 @@ private fun onboardingAdapterItems(onboardingState: OnboardingState): List<Adapt
it.getString(R.string.onboarding_feature_section_header, appName)
},
AdapterItem.OnboardingWhatsNew,
AdapterItem.OnboardingThemePicker,
AdapterItem.OnboardingTrackingProtection,
AdapterItem.OnboardingThemePicker,
AdapterItem.OnboardingPrivateBrowsing,
AdapterItem.OnboardingToolbarPositionPicker,
AdapterItem.OnboardingPrivacyNotice,
......
......@@ -17,8 +17,12 @@ import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.onboarding_private_browsing.view.*
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.setBounds
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(view) {
class OnboardingPrivateBrowsingViewHolder(
view: View,
private val interactor: OnboardingInteractor
) : RecyclerView.ViewHolder(view) {
init {
view.header_text.setOnboardingIcon(R.drawable.ic_onboarding_private_browsing)
......@@ -27,7 +31,7 @@ class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(
val inlineIcon = PrivateBrowsingImageSpan(
view.context,
R.drawable.ic_private_browsing,
view.description_text.lineHeight
view.description_text_once.lineHeight
)
val text = SpannableString(view.context.getString(R.string.onboarding_private_browsing_description1)).apply {
......@@ -40,8 +44,11 @@ class OnboardingPrivateBrowsingViewHolder(view: View) : RecyclerView.ViewHolder(
)
}
view.description_text.text = text
view.description_text_once.text = text
view.contentDescription = String.format(text.toString(), view.header_text.text)
view.open_settings_button.setOnClickListener {
interactor.onOpenSettingsClicked()
}
}
class PrivateBrowsingImageSpan(
......
......@@ -24,14 +24,53 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<TextView
android:id="@+id/description_text"
android:id="@+id/description_text_once"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/Body14TextStyle"
android:layout_marginTop="14dp"
tools:text="@string/onboarding_private_browsing_description"
tools:text="@string/onboarding_private_browsing_description1"
app:layout_constraintTop_toBottomOf="@id/header_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toTopOf="@id/description_text_always" />
<TextView
android:id="@+id/description_text_always"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/Body14TextStyle"
android:layout_marginTop="14dp"
android:text="@string/onboarding_private_browsing_always_description"
app:layout_constraintTop_toBottomOf="@id/description_text_once"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toTopOf="@id/open_settings_button" />
<FrameLayout
android:id="@+id/open_settings_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:background="@drawable/button_background"
android:backgroundTint="?neutralFaded"
android:clickable="true"
android:focusable="true"
android:foreground="?android:attr/selectableItemBackground"
android:padding="10dp"
app:layout_constraintTop_toBottomOf="@id/description_text_always"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:focusable="false"
android:textStyle="bold"
android:gravity="center"
android:text="@string/onboarding_private_browsing_button"
android:textColor="?primaryText"
android:textSize="14sp" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -92,6 +92,9 @@
<action
android:id="@+id/action_homeFragment_to_shareFragment"
app:destination="@id/shareFragment" />
<action
android:id="@+id/action_homeFragment_to_privateBrowsingFragment"
app:destination="@id/privateBrowsingFragment" />
</fragment>
<fragment
......
......@@ -47,6 +47,7 @@ class DefaultSessionControlControllerTest {
private val closeAllTabs: (isPrivateMode: Boolean) -> Unit = mockk(relaxed = true)
private val getListOfTabs: () -> List<Tab> = { emptyList() }
private val hideOnboarding: () -> Unit = mockk(relaxed = true)
private val openSettingsScreen: () -> Unit = mockk(relaxed = true)
private val invokePendingDeleteJobs: () -> Unit = mockk(relaxed = true)
private val registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true)
private val scrollToTheTop: () -> Unit = mockk(relaxed = true)
......@@ -81,7 +82,8 @@ class DefaultSessionControlControllerTest {
invokePendingDeleteJobs = invokePendingDeleteJobs,
registerCollectionStorageObserver = registerCollectionStorageObserver,
scrollToTheTop = scrollToTheTop,
showDeleteCollectionPrompt = showDeleteCollectionPrompt
showDeleteCollectionPrompt = showDeleteCollectionPrompt,
openSettingsScreen = openSettingsScreen
)
}
......@@ -199,6 +201,12 @@ class DefaultSessionControlControllerTest {
verify { hideOnboarding() }
}
@Test
fun handleOpenSettingsClicked() {
controller.handleOpenSettingsClicked()
verify { openSettingsScreen() }
}
@Test
fun handleToggleCollectionExpanded() {
val collection: TabCollection = mockk(relaxed = true)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment