Browse Source

For #6980: Update Private browsing card.

Added test to description.
Added link to settings.
Updated unit tests.
master
mcarare 2 years ago
committed by Jeff Boek
parent
commit
372b1e7f0e
  1. 8
      app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
  2. 2
      app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt
  3. 12
      app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt
  4. 9
      app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt
  5. 2
      app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt
  6. 13
      app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingPrivateBrowsingViewHolder.kt
  7. 45
      app/src/main/res/layout/onboarding_private_browsing.xml
  8. 3
      app/src/main/res/navigation/nav_graph.xml
  9. 10
      app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt

8
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt

@ -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) {

2
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlAdapter.kt

@ -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)

12
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt

@ -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))
}

9
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlInteractor.kt

@ -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)
}

2
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlView.kt

@ -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,

13
app/src/main/java/org/mozilla/fenix/home/sessioncontrol/viewholders/onboarding/OnboardingPrivateBrowsingViewHolder.kt

@ -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(

45
app/src/main/res/layout/onboarding_private_browsing.xml

@ -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>

3
app/src/main/res/navigation/nav_graph.xml

@ -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

10
app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt

@ -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)

Loading…
Cancel
Save