mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-09 19:10:42 +00:00
* For #9687: Refactor onboarding cards to follow app architecture * For #9687: Update unit test to new controller parameters
This commit is contained in:
parent
025656d8fd
commit
dfded8e69c
@ -217,7 +217,9 @@ class HomeFragment : Fragment() {
|
|||||||
scrollToTheTop = ::scrollToTheTop,
|
scrollToTheTop = ::scrollToTheTop,
|
||||||
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt,
|
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt,
|
||||||
openSettingsScreen = ::openSettingsScreen,
|
openSettingsScreen = ::openSettingsScreen,
|
||||||
openSearchScreen = ::navigateToSearch
|
openSearchScreen = ::navigateToSearch,
|
||||||
|
openWhatsNewLink = { openCustomTab(SupportUtils.getWhatsNewUrl(view.context)) },
|
||||||
|
openPrivacyNotice = { openCustomTab(SupportUtils.getPrivacyNoticeUrl()) }
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
updateLayout(view)
|
updateLayout(view)
|
||||||
@ -592,6 +594,13 @@ class HomeFragment : Fragment() {
|
|||||||
nav(R.id.homeFragment, directions)
|
nav(R.id.homeFragment, directions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun openCustomTab(url: String) {
|
||||||
|
context?.let { context ->
|
||||||
|
val intent = SupportUtils.createCustomTabIntent(context, url)
|
||||||
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("ComplexMethod", "LongMethod")
|
@SuppressWarnings("ComplexMethod", "LongMethod")
|
||||||
private fun createHomeMenu(context: Context, menuButtonView: WeakReference<MenuButton>) = HomeMenu(
|
private fun createHomeMenu(context: Context, menuButtonView: WeakReference<MenuButton>) = HomeMenu(
|
||||||
this,
|
this,
|
||||||
|
@ -182,9 +182,9 @@ class SessionControlAdapter(
|
|||||||
OnboardingThemePickerViewHolder.LAYOUT_ID -> OnboardingThemePickerViewHolder(view)
|
OnboardingThemePickerViewHolder.LAYOUT_ID -> OnboardingThemePickerViewHolder(view)
|
||||||
OnboardingTrackingProtectionViewHolder.LAYOUT_ID -> OnboardingTrackingProtectionViewHolder(view)
|
OnboardingTrackingProtectionViewHolder.LAYOUT_ID -> OnboardingTrackingProtectionViewHolder(view)
|
||||||
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view, interactor)
|
OnboardingPrivateBrowsingViewHolder.LAYOUT_ID -> OnboardingPrivateBrowsingViewHolder(view, interactor)
|
||||||
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view)
|
OnboardingPrivacyNoticeViewHolder.LAYOUT_ID -> OnboardingPrivacyNoticeViewHolder(view, interactor)
|
||||||
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
|
OnboardingFinishViewHolder.LAYOUT_ID -> OnboardingFinishViewHolder(view, interactor)
|
||||||
OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view)
|
OnboardingWhatsNewViewHolder.LAYOUT_ID -> OnboardingWhatsNewViewHolder(view, interactor)
|
||||||
OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID -> OnboardingToolbarPositionPickerViewHolder(view)
|
OnboardingToolbarPositionPickerViewHolder.LAYOUT_ID -> OnboardingToolbarPositionPickerViewHolder(view)
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
|
@ -144,6 +144,16 @@ interface SessionControlController {
|
|||||||
*/
|
*/
|
||||||
fun handleOpenSettingsClicked()
|
fun handleOpenSettingsClicked()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see [OnboardingInteractor.onWhatsNewGetAnswersClicked]
|
||||||
|
*/
|
||||||
|
fun handleWhatsNewGetAnswersClicked()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see [OnboardingInteractor.onReadPrivacyNoticeClicked]
|
||||||
|
*/
|
||||||
|
fun handleReadPrivacyNoticeClicked()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see [CollectionInteractor.onToggleCollectionExpanded]
|
* @see [CollectionInteractor.onToggleCollectionExpanded]
|
||||||
*/
|
*/
|
||||||
@ -172,7 +182,9 @@ class DefaultSessionControlController(
|
|||||||
private val scrollToTheTop: () -> Unit,
|
private val scrollToTheTop: () -> Unit,
|
||||||
private val showDeleteCollectionPrompt: (tabCollection: TabCollection) -> Unit,
|
private val showDeleteCollectionPrompt: (tabCollection: TabCollection) -> Unit,
|
||||||
private val openSettingsScreen: () -> Unit,
|
private val openSettingsScreen: () -> Unit,
|
||||||
private val openSearchScreen: () -> Unit
|
private val openSearchScreen: () -> Unit,
|
||||||
|
private val openWhatsNewLink: () -> Unit,
|
||||||
|
private val openPrivacyNotice: () -> Unit
|
||||||
) : SessionControlController {
|
) : SessionControlController {
|
||||||
private val metrics: MetricController
|
private val metrics: MetricController
|
||||||
get() = activity.components.analytics.metrics
|
get() = activity.components.analytics.metrics
|
||||||
@ -358,6 +370,14 @@ class DefaultSessionControlController(
|
|||||||
openSettingsScreen()
|
openSettingsScreen()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun handleWhatsNewGetAnswersClicked() {
|
||||||
|
openWhatsNewLink()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun handleReadPrivacyNoticeClicked() {
|
||||||
|
openPrivacyNotice()
|
||||||
|
}
|
||||||
|
|
||||||
override fun handleToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
|
override fun handleToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
|
||||||
fragmentStore.dispatch(HomeFragmentAction.CollectionExpanded(collection, expand))
|
fragmentStore.dispatch(HomeFragmentAction.CollectionExpanded(collection, expand))
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,16 @@ interface OnboardingInteractor {
|
|||||||
* Hides the onboarding and navigates to Settings. Called when a user clicks on the "Open settings" button.
|
* Hides the onboarding and navigates to Settings. Called when a user clicks on the "Open settings" button.
|
||||||
*/
|
*/
|
||||||
fun onOpenSettingsClicked()
|
fun onOpenSettingsClicked()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a custom tab to what's new url. Called when a user clicks on the "Get answers here" link.
|
||||||
|
*/
|
||||||
|
fun onWhatsNewGetAnswersClicked()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens a custom tab to privacy notice url. Called when a user clicks on the "read our privacy notice" button.
|
||||||
|
*/
|
||||||
|
fun onReadPrivacyNoticeClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,6 +286,14 @@ class SessionControlInteractor(
|
|||||||
controller.handleOpenSettingsClicked()
|
controller.handleOpenSettingsClicked()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onWhatsNewGetAnswersClicked() {
|
||||||
|
controller.handleWhatsNewGetAnswersClicked()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onReadPrivacyNoticeClicked() {
|
||||||
|
controller.handleReadPrivacyNoticeClicked()
|
||||||
|
}
|
||||||
|
|
||||||
override fun onToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
|
override fun onToggleCollectionExpanded(collection: TabCollection, expand: Boolean) {
|
||||||
controller.handleToggleCollectionExpanded(collection, expand)
|
controller.handleToggleCollectionExpanded(collection, expand)
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,12 @@ import android.view.View
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.*
|
import kotlinx.android.synthetic.main.onboarding_privacy_notice.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.settings.SupportUtils
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
class OnboardingPrivacyNoticeViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
class OnboardingPrivacyNoticeViewHolder(
|
||||||
|
view: View,
|
||||||
|
private val interactor: OnboardingInteractor
|
||||||
|
) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view.header_text.setOnboardingIcon(R.drawable.ic_onboarding_privacy_notice)
|
view.header_text.setOnboardingIcon(R.drawable.ic_onboarding_privacy_notice)
|
||||||
@ -19,8 +22,7 @@ class OnboardingPrivacyNoticeViewHolder(view: View) : RecyclerView.ViewHolder(vi
|
|||||||
view.description_text.text = view.context.getString(R.string.onboarding_privacy_notice_description, appName)
|
view.description_text.text = view.context.getString(R.string.onboarding_privacy_notice_description, appName)
|
||||||
|
|
||||||
view.read_button.setOnClickListener {
|
view.read_button.setOnClickListener {
|
||||||
val intent = SupportUtils.createCustomTabIntent(view.context, SupportUtils.getPrivacyNoticeUrl())
|
interactor.onReadPrivacyNoticeClicked()
|
||||||
view.context.startActivity(intent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,9 +10,12 @@ import android.view.View
|
|||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import kotlinx.android.synthetic.main.onboarding_whats_new.view.*
|
import kotlinx.android.synthetic.main.onboarding_whats_new.view.*
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.settings.SupportUtils
|
import org.mozilla.fenix.home.sessioncontrol.OnboardingInteractor
|
||||||
|
|
||||||
class OnboardingWhatsNewViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
class OnboardingWhatsNewViewHolder(
|
||||||
|
view: View,
|
||||||
|
private val interactor: OnboardingInteractor
|
||||||
|
) : RecyclerView.ViewHolder(view) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
view.header_text.setOnboardingIcon(R.drawable.ic_whats_new)
|
view.header_text.setOnboardingIcon(R.drawable.ic_whats_new)
|
||||||
@ -27,8 +30,7 @@ class OnboardingWhatsNewViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
|||||||
|
|
||||||
view.get_answers.text = textWithLink
|
view.get_answers.text = textWithLink
|
||||||
view.get_answers.setOnClickListener {
|
view.get_answers.setOnClickListener {
|
||||||
val intent = SupportUtils.createCustomTabIntent(view.context, SupportUtils.getWhatsNewUrl(view.context))
|
interactor.onWhatsNewGetAnswersClicked()
|
||||||
view.context.startActivity(intent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +50,8 @@ class DefaultSessionControlControllerTest {
|
|||||||
private val hideOnboarding: () -> Unit = mockk(relaxed = true)
|
private val hideOnboarding: () -> Unit = mockk(relaxed = true)
|
||||||
private val openSettingsScreen: () -> Unit = mockk(relaxed = true)
|
private val openSettingsScreen: () -> Unit = mockk(relaxed = true)
|
||||||
private val openSearchScreen: () -> Unit = mockk(relaxed = true)
|
private val openSearchScreen: () -> Unit = mockk(relaxed = true)
|
||||||
|
private val openWhatsNewLink: () -> Unit = mockk(relaxed = true)
|
||||||
|
private val openPrivacyNotice: () -> Unit = mockk(relaxed = true)
|
||||||
private val invokePendingDeleteJobs: () -> Unit = mockk(relaxed = true)
|
private val invokePendingDeleteJobs: () -> Unit = mockk(relaxed = true)
|
||||||
private val registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true)
|
private val registerCollectionStorageObserver: () -> Unit = mockk(relaxed = true)
|
||||||
private val scrollToTheTop: () -> Unit = mockk(relaxed = true)
|
private val scrollToTheTop: () -> Unit = mockk(relaxed = true)
|
||||||
@ -96,7 +98,9 @@ class DefaultSessionControlControllerTest {
|
|||||||
scrollToTheTop = scrollToTheTop,
|
scrollToTheTop = scrollToTheTop,
|
||||||
showDeleteCollectionPrompt = showDeleteCollectionPrompt,
|
showDeleteCollectionPrompt = showDeleteCollectionPrompt,
|
||||||
openSettingsScreen = openSettingsScreen,
|
openSettingsScreen = openSettingsScreen,
|
||||||
openSearchScreen = openSearchScreen
|
openSearchScreen = openSearchScreen,
|
||||||
|
openWhatsNewLink = openWhatsNewLink,
|
||||||
|
openPrivacyNotice = openPrivacyNotice
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user