Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import android.os.Bundle
import android.view.View
import android.view.View.OnClickListener
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.runtime.collectAsState
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment
Expand Down Expand Up @@ -52,7 +51,6 @@ import org.wordpress.android.ui.about.UnifiedAboutActivity
import org.wordpress.android.ui.accounts.HelpActivity.Origin.ME_SCREEN_HELP
import org.wordpress.android.ui.debug.DebugSettingsActivity
import org.wordpress.android.ui.deeplinks.DeepLinkOpenWebLinksWithJetpackHelper
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil
import org.wordpress.android.ui.main.MeViewModel.RecommendAppUiState
import org.wordpress.android.ui.main.WPMainActivity.OnScrollToTopListener
import org.wordpress.android.ui.main.emailverificationbanner.EmailVerificationBanner
Expand Down Expand Up @@ -129,9 +127,6 @@ class MeFragment : Fragment(R.layout.me_fragment), OnScrollToTopListener {
@Inject
lateinit var uiHelpers: UiHelpers

@Inject
lateinit var jetpackFeatureRemovalUtils: JetpackFeatureRemovalOverlayUtil

@Inject
lateinit var domainManagementFeatureConfig: DomainManagementFeatureConfig

Expand Down Expand Up @@ -168,8 +163,11 @@ class MeFragment : Fragment(R.layout.me_fragment), OnScrollToTopListener {

@Suppress("LongMethod")
private fun MeFragmentBinding.setupViews() {
if (!BuildConfig.IS_JETPACK_APP && jetpackFeatureRemovalUtils.shouldHideJetpackFeatures()) {
with(requireActivity() as AppCompatActivity) {
// MeActivity hosts this fragment on its own, so it needs a toolbar; inside the bottom
// navigation's pager the host activity already provides one.
val meActivity = activity as? MeActivity
if (meActivity != null) {
with(meActivity) {
setSupportActionBar(toolbarMain)
supportActionBar?.apply {
setHomeButtonEnabled(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class SiteItemsBuilder @Inject constructor(
List<MySiteCardAndItem> {
return listOfNotNull(
siteListItemBuilder.buildDomainsItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildMeItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildMeItemIfAvailable(params.onClick),
siteListItemBuilder.buildSiteSettingsItemIfAvailable(params.site, params.onClick),
siteListItemBuilder.buildApplicationPasswordsItemIfAvailable(params.site, params.onClick),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,17 @@ class SiteListItemBuilder @Inject constructor(
} else null
}

@Suppress("ComplexCondition")
fun buildMeItemIfAvailable(site: SiteModel, onClick: (ListItemAction) -> Unit): ListItem? {
return if ((!buildConfigWrapper.isJetpackApp &&
jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures() &&
site.hasCapabilityManageOptions) ||
(!buildConfigWrapper.isJetpackApp &&
site.isSelfHostedAdmin)
) {
/**
* The Me item replaces the bottom navigation's Me tab when that nav is hidden, so it's gated on
* exactly the same condition WPMainActivity uses to hide it. Me is account-level, so site
* capabilities deliberately play no part here.
*
* No explicit Jetpack app check is needed: [JetpackFeatureRemovalPhaseHelper.getCurrentPhase]
* returns null there, so [JetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures] is
* always false and the item never builds.
*/
fun buildMeItemIfAvailable(onClick: (ListItemAction) -> Unit): ListItem? {
return if (jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()) {
ListItem(
R.drawable.ic_user_primary_white_24,
UiStringRes(R.string.me),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ val DOMAINS_ITEM = ListItem(
onClick = ListItemInteraction.create(DOMAINS, SITE_ITEM_ACTION),
listItemAction = DOMAINS
)
val ME_ITEM = ListItem(
R.drawable.ic_user_primary_white_24,
UiStringRes(R.string.me),
onClick = ListItemInteraction.create(ListItemAction.ME, SITE_ITEM_ACTION),
disablePrimaryIconTint = true,
listItemAction = ListItemAction.ME
)
val SITE_MONITORING_ITEM = ListItem(
R.drawable.gb_ic_tool,
UiStringRes(R.string.site_monitoring),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.ui.mysite.items.ACTIVITY_ITEM
import org.wordpress.android.ui.mysite.items.ADMIN_ITEM
import org.wordpress.android.ui.mysite.items.BACKUP_ITEM
import org.wordpress.android.ui.mysite.items.ME_ITEM
import org.wordpress.android.ui.mysite.items.PAGES_ITEM
import org.wordpress.android.ui.mysite.items.PEOPLE_ITEM
import org.wordpress.android.ui.mysite.items.PLUGINS_ITEM
Expand Down Expand Up @@ -337,6 +338,26 @@ class SiteListItemBuilderTest {
assertThat(item).isNull()
}

// Me stands in for the bottom navigation once Jetpack features are removed, so it is built
// for every site regardless of capabilities.
@Test
fun `me item built when jetpack features are removed, regardless of site capabilities`() {
whenever(jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()).thenReturn(true)

val item = siteListItemBuilder.buildMeItemIfAvailable(SITE_ITEM_ACTION)

assertThat(item).isEqualTo(ME_ITEM)
}

@Test
fun `me item not built when jetpack features are not removed`() {
whenever(jetpackFeatureRemovalPhaseHelper.shouldRemoveJetpackFeatures()).thenReturn(false)

val item = siteListItemBuilder.buildMeItemIfAvailable(SITE_ITEM_ACTION)

assertThat(item).isNull()
}

/* SITE MONITORING */
@Test
fun `give jetpack app, when FF is true and site is atomic and admin, then site monitoring item is built`() {
Expand Down
Loading