From 79748d6cf3997f3c34941e8912bde55ae4214440 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:21:11 +0530 Subject: [PATCH 01/23] - Removes: QuickStartExistingUsersV2FeatureConfig.kt --- WordPress/build.gradle | 1 - .../cards/quickstart/QuickStartRepository.kt | 4 --- .../QuickStartExistingUsersV2FeatureConfig.kt | 25 ------------------- 3 files changed, 30 deletions(-) delete mode 100644 WordPress/src/main/java/org/wordpress/android/util/config/QuickStartExistingUsersV2FeatureConfig.kt diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 4b4d4233800b..5895c6ee65a7 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -117,7 +117,6 @@ android { buildConfigField "boolean", "SITE_NAME", "false" buildConfigField "boolean", "LANDING_SCREEN_REVAMP", "true" buildConfigField "boolean", "LAND_ON_THE_EDITOR", "false" - buildConfigField "boolean", "QUICK_START_EXISTING_USERS_V2", "false" buildConfigField "boolean", "QRCODE_AUTH_FLOW", "false" buildConfigField "boolean", "BETA_SITE_DESIGNS", "false" buildConfigField "boolean", "JETPACK_POWERED", "true" diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepository.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepository.kt index 145041052a9a..9a9b14bd18c0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepository.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepository.kt @@ -38,7 +38,6 @@ import org.wordpress.android.util.EventBusWrapper import org.wordpress.android.util.HtmlCompatWrapper import org.wordpress.android.util.QuickStartUtilsWrapper import org.wordpress.android.util.SiteUtils -import org.wordpress.android.util.config.QuickStartExistingUsersV2FeatureConfig import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.ResourceProvider @@ -62,7 +61,6 @@ class QuickStartRepository private val contextProvider: ContextProvider, private val htmlMessageUtils: HtmlMessageUtils, private val quickStartTracker: QuickStartTracker, - quickStartForExistingUsersV2FeatureConfig: QuickStartExistingUsersV2FeatureConfig ) : CoroutineScope { private val job: Job = Job() override val coroutineContext: CoroutineContext @@ -78,7 +76,6 @@ class QuickStartRepository val onQuickStartMySitePrompts = _onQuickStartMySitePrompts as LiveData> val activeTask = _activeTask as LiveData val isQuickStartNoticeShown = _isQuickStartNoticeShown - val isQuickStartForExistingUsersV2FeatureEnabled = quickStartForExistingUsersV2FeatureConfig.isEnabled() val quickStartType: QuickStartType get() = selectedSiteRepository.getSelectedSite()?.let { val siteLocalId = it.id.toLong() @@ -107,7 +104,6 @@ class QuickStartRepository } fun checkAndSetQuickStartType(isNewSite: Boolean) { - if (!isQuickStartForExistingUsersV2FeatureEnabled) return selectedSiteRepository.getSelectedSite()?.let { selectedSite -> val siteLocalId = selectedSite.id.toLong() val quickStartType = if (isNewSite) NewSiteQuickStartType else ExistingSiteQuickStartType diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/QuickStartExistingUsersV2FeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/QuickStartExistingUsersV2FeatureConfig.kt deleted file mode 100644 index 586d8ccfcd53..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/util/config/QuickStartExistingUsersV2FeatureConfig.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.wordpress.android.util.config - -import org.wordpress.android.BuildConfig -import org.wordpress.android.annotation.Feature -import javax.inject.Inject - -/** - * Configuration of the 'Quick Start for Existing Users V2' that will introduce a new set of - * Quick Start steps that are relevant to existing users. - */ -@Feature( - remoteField = QuickStartExistingUsersV2FeatureConfig.QUICK_START_EXISTING_USERS_V2, - defaultValue = true -) -class QuickStartExistingUsersV2FeatureConfig @Inject constructor( - appConfig: AppConfig -) : FeatureConfig( - appConfig, - BuildConfig.QUICK_START_EXISTING_USERS_V2, - QUICK_START_EXISTING_USERS_V2 -) { - companion object { - const val QUICK_START_EXISTING_USERS_V2 = "quick_start_existing_users_v2" - } -} From 8b17f18d1ac8677d655843b13b0d224f84727fe3 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:22:35 +0530 Subject: [PATCH 02/23] - Removes: QuickStartExistingUsersV2FeatureConfig from tests --- .../mysite/cards/quickstart/QuickStartCardSourceTest.kt | 8 +------- .../mysite/cards/quickstart/QuickStartRepositoryTest.kt | 8 +------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt index 9b641e5c291f..4ecde353a683 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt @@ -39,7 +39,6 @@ import org.wordpress.android.util.EventBusWrapper import org.wordpress.android.util.HtmlCompatWrapper import org.wordpress.android.util.QuickStartUtilsWrapper import org.wordpress.android.util.config.MySiteDashboardTabsFeatureConfig -import org.wordpress.android.util.config.QuickStartExistingUsersV2FeatureConfig import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.ResourceProvider @@ -81,9 +80,6 @@ class QuickStartCardSourceTest : BaseUnitTest() { @Mock lateinit var mySiteDashboardTabsFeatureConfig: MySiteDashboardTabsFeatureConfig - @Mock - lateinit var quickStartExistingUsersV2FeatureConfig: QuickStartExistingUsersV2FeatureConfig - @Mock lateinit var quickStartTracker: QuickStartTracker private lateinit var site: SiteModel @@ -103,7 +99,6 @@ class QuickStartCardSourceTest : BaseUnitTest() { site.id = siteLocalId whenever(selectedSiteRepository.getSelectedSite()).thenReturn(site) whenever(appPrefsWrapper.getLastSelectedQuickStartTypeForSite(any())).thenReturn(NewSiteQuickStartType) - whenever(quickStartExistingUsersV2FeatureConfig.isEnabled()).thenReturn(false) whenever(quickStartUtilsWrapper.isQuickStartAvailableForTheSite(site)).thenReturn(true) quickStartRepository = QuickStartRepository( testDispatcher(), @@ -117,8 +112,7 @@ class QuickStartCardSourceTest : BaseUnitTest() { htmlCompat, contextProvider, htmlMessageUtils, - quickStartTracker, - quickStartExistingUsersV2FeatureConfig + quickStartTracker ) quickStartCardSource = QuickStartCardSource( quickStartRepository, diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepositoryTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepositoryTest.kt index 8af6e72e6247..53944813d08a 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepositoryTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartRepositoryTest.kt @@ -32,7 +32,6 @@ import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.EventBusWrapper import org.wordpress.android.util.HtmlCompatWrapper import org.wordpress.android.util.QuickStartUtilsWrapper -import org.wordpress.android.util.config.QuickStartExistingUsersV2FeatureConfig import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.ResourceProvider @@ -71,9 +70,6 @@ class QuickStartRepositoryTest : BaseUnitTest() { @Mock lateinit var buildConfigWrapper: BuildConfigWrapper - @Mock - lateinit var quickStartExistingUsersV2FeatureConfig: QuickStartExistingUsersV2FeatureConfig - @Mock lateinit var quickStartType: QuickStartType @@ -88,7 +84,6 @@ class QuickStartRepositoryTest : BaseUnitTest() { @Before fun setUp() = test { whenever(appPrefsWrapper.getLastSelectedQuickStartTypeForSite(any())).thenReturn(quickStartType) - whenever(quickStartExistingUsersV2FeatureConfig.isEnabled()).thenReturn(false) quickStartRepository = QuickStartRepository( testDispatcher(), quickStartStore, @@ -101,8 +96,7 @@ class QuickStartRepositoryTest : BaseUnitTest() { htmlCompat, contextProvider, htmlMessageUtils, - quickStartTracker, - quickStartExistingUsersV2FeatureConfig + quickStartTracker ) snackbars = mutableListOf() quickStartPrompts = mutableListOf() From 190caf9d83dacd4fd04bfface08662614fa4a7a9 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:25:49 +0530 Subject: [PATCH 03/23] - Removes: MySiteDashboardTabsFeatureConfig.kt from tests and gradle --- WordPress/build.gradle | 3 --- .../MySiteDashboardTabsFeatureConfig.kt | 25 ------------------- .../android/ui/mysite/MySiteViewModelTest.kt | 5 ---- .../quickstart/QuickStartCardSourceTest.kt | 4 --- 4 files changed, 37 deletions(-) delete mode 100644 WordPress/src/main/java/org/wordpress/android/util/config/MySiteDashboardTabsFeatureConfig.kt diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 5895c6ee65a7..f2c378e25e97 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -109,7 +109,6 @@ android { buildConfigField "boolean", "GLOBAL_STYLE_SUPPORT", "true" buildConfigField "boolean", "QUICK_START_DYNAMIC_CARDS", "false" buildConfigField "boolean", "RECOMMEND_THE_APP", "false" - buildConfigField "boolean", "MY_SITE_DASHBOARD_TABS", "false" buildConfigField "boolean", "UNIFIED_COMMENTS_DETAILS", "false" buildConfigField "boolean", "COMMENTS_SNIPPET", "false" buildConfigField "boolean", "READER_COMMENTS_MODERATION", "false" @@ -153,7 +152,6 @@ android { buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" buildConfigField "boolean", "ENABLE_FOLLOWED_SITES_SETTINGS", "true" buildConfigField "boolean", "ENABLE_WHATS_NEW_FEATURE", "true" - buildConfigField "boolean", "ENABLE_MY_SITE_DASHBOARD_TABS", "true" buildConfigField "boolean", "ENABLE_QRCODE_AUTH_FLOW", "true" buildConfigField "boolean", "ENABLE_OPEN_WEB_LINKS_WITH_JP_FLOW", "true" buildConfigField "boolean", "BLAZE_MANAGE_CAMPAIGNS", "false" @@ -200,7 +198,6 @@ android { buildConfigField "boolean", "ENABLE_CREATE_FAB", "true" buildConfigField "boolean", "ENABLE_FOLLOWED_SITES_SETTINGS", "true" buildConfigField "boolean", "ENABLE_WHATS_NEW_FEATURE", "true" - buildConfigField "boolean", "ENABLE_MY_SITE_DASHBOARD_TABS", "true" buildConfigField "String", "TRACKS_EVENT_PREFIX", '"jpandroid_"' buildConfigField "String", "PUSH_NOTIFICATIONS_APP_KEY", '"com.jetpack.android"' buildConfigField "boolean", "ENABLE_QRCODE_AUTH_FLOW", "true" diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/MySiteDashboardTabsFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/MySiteDashboardTabsFeatureConfig.kt deleted file mode 100644 index 2e26dee3cf4c..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/util/config/MySiteDashboardTabsFeatureConfig.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.wordpress.android.util.config - -import org.wordpress.android.BuildConfig -import org.wordpress.android.annotation.Feature -import org.wordpress.android.util.config.MySiteDashboardTabsFeatureConfig.Companion.MY_SITE_DASHBOARD_TABS -import javax.inject.Inject - -/** - * Configuration of the 'My Site Dashboard - Tabs' that will display tabs on the 'My Site' screen. - */ -@Feature( - remoteField = MY_SITE_DASHBOARD_TABS, - defaultValue = true -) -class MySiteDashboardTabsFeatureConfig @Inject constructor( - appConfig: AppConfig -) : FeatureConfig( - appConfig, - BuildConfig.MY_SITE_DASHBOARD_TABS, - MY_SITE_DASHBOARD_TABS -) { - companion object { - const val MY_SITE_DASHBOARD_TABS = "my_site_dashboard_tabs" - } -} diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt index 7ec6602ac0b6..367551ba8526 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/MySiteViewModelTest.kt @@ -119,7 +119,6 @@ import org.wordpress.android.util.QuickStartUtilsWrapper import org.wordpress.android.util.SnackbarSequencer import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.config.LandOnTheEditorFeatureConfig -import org.wordpress.android.util.config.MySiteDashboardTabsFeatureConfig import org.wordpress.android.util.publicdata.AppStatus import org.wordpress.android.util.publicdata.WordPressPublicData import org.wordpress.android.viewmodel.Event @@ -186,9 +185,6 @@ class MySiteViewModelTest : BaseUnitTest() { @Mock lateinit var buildConfigWrapper: BuildConfigWrapper - @Mock - lateinit var mySiteDashboardTabsFeatureConfig: MySiteDashboardTabsFeatureConfig - @Mock lateinit var getShowJetpackFullPluginInstallOnboardingUseCase: GetShowJetpackFullPluginInstallOnboardingUseCase @@ -443,7 +439,6 @@ class MySiteViewModelTest : BaseUnitTest() { cardsTracker, domainRegistrationCardShownTracker, buildConfigWrapper, - mySiteDashboardTabsFeatureConfig, jetpackBrandingUtils, appPrefsWrapper, quickStartTracker, diff --git a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt index 4ecde353a683..a58b40fa5909 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/mysite/cards/quickstart/QuickStartCardSourceTest.kt @@ -38,7 +38,6 @@ import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.EventBusWrapper import org.wordpress.android.util.HtmlCompatWrapper import org.wordpress.android.util.QuickStartUtilsWrapper -import org.wordpress.android.util.config.MySiteDashboardTabsFeatureConfig import org.wordpress.android.viewmodel.ContextProvider import org.wordpress.android.viewmodel.ResourceProvider @@ -77,9 +76,6 @@ class QuickStartCardSourceTest : BaseUnitTest() { @Mock lateinit var buildConfigWrapper: BuildConfigWrapper - @Mock - lateinit var mySiteDashboardTabsFeatureConfig: MySiteDashboardTabsFeatureConfig - @Mock lateinit var quickStartTracker: QuickStartTracker private lateinit var site: SiteModel From 929b7e4bdd5f5a98af1f5ac0e9c3676ebae873b4 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:27:18 +0530 Subject: [PATCH 04/23] + Adds: logic to set the quick start item in quick link items --- .../QuickLinksItemViewModelSlice.kt | 97 ++++++++++++------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt index 591064d2369e..1754060ec5b1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt @@ -7,6 +7,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import org.wordpress.android.R import org.wordpress.android.fluxc.model.SiteModel +import org.wordpress.android.fluxc.store.QuickStartStore import org.wordpress.android.modules.BG_THREAD import org.wordpress.android.ui.blaze.BlazeFeatureUtils import org.wordpress.android.ui.jetpack.JetpackCapabilitiesUseCase @@ -32,12 +33,15 @@ class QuickLinksItemViewModelSlice @Inject constructor( private val jetpackCapabilitiesUseCase: JetpackCapabilitiesUseCase, private val listItemActionHandler: ListItemActionHandler, private val blazeFeatureUtils: BlazeFeatureUtils, - private val appPrefsWrapper: AppPrefsWrapper + private val appPrefsWrapper: AppPrefsWrapper, ) { lateinit var scope: CoroutineScope + lateinit var site: SiteModel + fun initialization(scope: CoroutineScope) { this.scope = scope + this.site = selectedSiteRepository.getSelectedSite()!! } private val _onNavigation = MutableLiveData>() @@ -50,43 +54,18 @@ class QuickLinksItemViewModelSlice @Inject constructor( val uiState: LiveData = _uiState fun start() { - selectedSiteRepository.getSelectedSite()?.let { - buildQuickLinks(it) - } + buildQuickLinks() } fun onResume() { - selectedSiteRepository.getSelectedSite()?.let { - buildQuickLinks(it) - } + buildQuickLinks() } fun onRefresh() { - selectedSiteRepository.getSelectedSite()?.let { - buildQuickLinks(it) - } + buildQuickLinks() } - private fun buildQuickLinks(site: SiteModel) { - scope.launch { - _uiState.postValue( - convertToQuickLinkRibbonItem( - siteItemsBuilder.build( - MySiteCardAndItemBuilderParams.SiteItemsBuilderParams( - enableFocusPoints = true, - site = site, - activeTask = null, - onClick = this@QuickLinksItemViewModelSlice::onClick, - isBlazeEligible = isSiteBlazeEligible() - ) - ) - ) - ) - updateSiteItemsForJetpackCapabilities(site) - } - } - - private fun updateSiteItemsForJetpackCapabilities(site: SiteModel) { + private fun buildQuickLinks() { scope.launch(bgDispatcher) { jetpackCapabilitiesUseCase.getJetpackPurchasedProducts(site.siteId).collect { _uiState.postValue( @@ -101,15 +80,16 @@ class QuickLinksItemViewModelSlice @Inject constructor( backupAvailable = it.backup, scanAvailable = (it.scan && !site.isWPCom && !site.isWPComAtomic) ) - ) + ), ) ) } // end collect } } - private fun convertToQuickLinkRibbonItem(listItems: List): - MySiteCardAndItem.Card.QuickLinkRibbon { + private fun convertToQuickLinkRibbonItem( + listItems: List, + ): MySiteCardAndItem.Card.QuickLinkRibbon { val siteId = selectedSiteRepository.getSelectedSite()!!.siteId val activeListItems = listItems.filterIsInstance(MySiteCardAndItem.Item.ListItem::class.java) .filter { isActiveQuickLink(it.listItemAction, siteId = siteId) } @@ -117,7 +97,8 @@ class QuickLinksItemViewModelSlice @Inject constructor( MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem( icon = listItem.primaryIcon, label = (listItem.primaryText as UiString.UiStringRes), - onClick = listItem.onClick + onClick = listItem.onClick, + listItemAction = listItem.listItemAction, ) } val moreQuickLink = MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem( @@ -126,7 +107,8 @@ class QuickLinksItemViewModelSlice @Inject constructor( onClick = ListItemInteraction.create( ListItemAction.MORE, this@QuickLinksItemViewModelSlice::onClick - ) + ), + listItemAction = ListItemAction.MORE ) return MySiteCardAndItem.Card.QuickLinkRibbon( quickLinkRibbonItems = activeQuickLinks + moreQuickLink @@ -141,7 +123,7 @@ class QuickLinksItemViewModelSlice @Inject constructor( selectedSiteRepository.getSelectedSite()?.let { selectedSite -> // add the tracking logic here _onNavigation.postValue(Event(listItemActionHandler.handleAction(action, selectedSite))) - }?: run { + } ?: run { _onSnackbarMessage.postValue( Event(SnackbarMessageHolder(UiString.UiStringRes(R.string.site_cannot_be_loaded))) ) @@ -175,4 +157,47 @@ class QuickLinksItemViewModelSlice @Inject constructor( ListItemAction.STATS ) } + + fun updateToShowMoreFocusPointIfNeeded( + quickLinks: MySiteCardAndItem.Card.QuickLinkRibbon, + activeTask: QuickStartStore.QuickStartTask + ): MySiteCardAndItem.Card.QuickLinkRibbon { + val updatedQuickLinks = if (shouldShowMoreFocusPoint(quickLinks.quickLinkRibbonItems, activeTask)) { + val quickLinkItems = quickLinks.quickLinkRibbonItems.toMutableList() + val lastItem = quickLinkItems.last().copy(showFocusPoint = true) + quickLinkItems.removeLast() + quickLinkItems.add(lastItem) + quickLinks.copy(quickLinkRibbonItems = quickLinkItems, showMoreFocusPoint = true) + } else { + quickLinks + } + return updatedQuickLinks + } + + private fun shouldShowMoreFocusPoint( + activeShortcuts: List, + activeTask: QuickStartStore.QuickStartTask? + ): Boolean { + if (activeTask == null) return false + activeShortcuts.find { it.listItemAction in isQuickStartFocusListItemAction() }?.let { + return isActiveTaskInMoreMenu(activeTask) + } + return false + } + + private fun isQuickStartFocusListItemAction(): List { + return listOf( + ListItemAction.POSTS, + ListItemAction.PAGES, + ListItemAction.STATS, + ListItemAction.MEDIA + ) + } + + private fun isActiveTaskInMoreMenu(activeTask: QuickStartStore.QuickStartTask?): Boolean { + return activeTask == QuickStartStore.QuickStartNewSiteTask.REVIEW_PAGES || + activeTask == QuickStartStore.QuickStartNewSiteTask.CHECK_STATS || + activeTask == QuickStartStore.QuickStartExistingSiteTask.UPLOAD_MEDIA || + activeTask == QuickStartStore.QuickStartNewSiteTask.ENABLE_POST_SHARING + } } From 5c2112987e6776c13343e5a2c8259a4d9be172f5 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:28:59 +0530 Subject: [PATCH 05/23] + Adds: the list item action as an identifier for quick start check --- .../java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt index e874ee9cb8bb..6416310d8257 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt @@ -95,7 +95,8 @@ sealed class MySiteCardAndItem(open val type: Type, open val activeQuickStartIte val label: UiString.UiStringRes, @DrawableRes val icon: Int, val onClick: ListItemInteraction, - val showFocusPoint: Boolean = false + val showFocusPoint: Boolean = false, + val listItemAction: ListItemAction ) } From 55d4c12665ae6cdcd19562f56b4e7f61f69d2a37 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:29:25 +0530 Subject: [PATCH 06/23] + Adds: the logic to show quick start focus point in quick links --- .../android/ui/mysite/MySiteViewModel.kt | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index eeb8ba447c05..c68dfbb9436d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -104,7 +104,6 @@ import org.wordpress.android.util.QuickStartUtilsWrapper import org.wordpress.android.util.SnackbarSequencer import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper import org.wordpress.android.util.config.LandOnTheEditorFeatureConfig -import org.wordpress.android.util.config.MySiteDashboardTabsFeatureConfig import org.wordpress.android.util.filter import org.wordpress.android.util.getEmailValidationMessage import org.wordpress.android.util.mapSafe @@ -140,7 +139,6 @@ class MySiteViewModel @Inject constructor( private val cardsTracker: CardsTracker, private val domainRegistrationCardShownTracker: DomainRegistrationCardShownTracker, private val buildConfigWrapper: BuildConfigWrapper, - mySiteDashboardTabsFeatureConfig: MySiteDashboardTabsFeatureConfig, private val jetpackBrandingUtils: JetpackBrandingUtils, private val appPrefsWrapper: AppPrefsWrapper, private val quickStartTracker: QuickStartTracker, @@ -182,13 +180,16 @@ class MySiteViewModel @Inject constructor( as they're already built on site select. */ private var isSiteSelected = false - private val isMySiteDashboardTabsEnabled by lazy { mySiteDashboardTabsFeatureConfig.isEnabled() } - - val isMySiteTabsEnabled: Boolean - get() = isMySiteDashboardTabsEnabled && - buildConfigWrapper.isMySiteTabsEnabled && - jetpackFeatureRemovalPhaseHelper.shouldShowDashboard() && - selectedSiteRepository.getSelectedSite()?.isUsingWpComRestApi ?: true + val quickLinks: LiveData = merge( + quickLinksItemViewModelSlice.uiState, + quickStartRepository.activeTask + ) { quickLinks, activeTask -> + if (quickLinks != null && + activeTask != null) { + return@merge quickLinksItemViewModelSlice.updateToShowMoreFocusPointIfNeeded(quickLinks, activeTask) + } + return@merge quickLinks + } val onScrollTo: LiveData> = merge( _activeTaskPosition.distinctUntilChanged(), @@ -265,7 +266,7 @@ class MySiteViewModel @Inject constructor( result.filter { it.siteId == null || it.state.site != null }.mapSafe { it.state } } - val uiModel: LiveData = merge(state, quickLinksItemViewModelSlice.uiState) { cards, quickLinks -> + val uiModel: LiveData = merge(state, quickLinks) { cards, quickLinks -> cards?.let { nonNullCards -> with(nonNullCards) { val state = if (site != null) { @@ -358,12 +359,12 @@ class MySiteViewModel @Inject constructor( if (activeTask != null) { scrollToQuickStartTaskIfNecessary( activeTask, - getPositionOfQuickStartItem(siteItems, activeTask) + getPositionOfQuickStartItem(siteItems) ) } // It is okay to use !! here because we are explicitly creating the lists return SiteSelected( - siteInfoHeader = siteInfo, + siteInfoHeader = siteInfo, siteMenuCardsAndItems = siteItems[MySiteTabType.SITE_MENU]!!, dashboardCardsAndItems = siteItems[MySiteTabType.DASHBOARD]!! ) @@ -371,17 +372,9 @@ class MySiteViewModel @Inject constructor( private fun getPositionOfQuickStartItem( siteItems: Map>, - activeTask: QuickStartTask ): Int { - return if(activeTask.shownInMoreMenu()) - (siteItems[MySiteTabType.DASHBOARD] as List) - .indexOfFirst { it.activeQuickStartItem } - else LIST_INDEX_NO_ACTIVE_QUICK_START_ITEM - } - - private fun QuickStartTask.shownInMoreMenu() = when (this) { - QuickStartNewSiteTask.ENABLE_POST_SHARING -> true - else -> false + return (siteItems[MySiteTabType.DASHBOARD] as List) + .indexOfFirst { it.activeQuickStartItem } } @Suppress("LongParameterList", "CyclomaticComplexMethod") @@ -480,7 +473,7 @@ class MySiteViewModel @Inject constructor( return mapOf( MySiteTabType.SITE_MENU to mutableListOf().apply { - infoItem?.let { add(infoItem)} + infoItem?.let { add(infoItem) } addAll(siteItems) jetpackSwitchMenu?.let { add(jetpackSwitchMenu) } if (jetpackFeatureCardHelper.shouldShowFeatureCardAtTop()) From b3cce7034abe54f27b98839c44e3677409940ad0 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 14:58:26 +0530 Subject: [PATCH 07/23] - Removes: MySiteTabsFeatureFlag from build wrappper --- .../main/java/org/wordpress/android/util/BuildConfigWrapper.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt index 614307a916d6..b7bd6a2a1c9d 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/util/BuildConfigWrapper.kt @@ -33,6 +33,4 @@ class BuildConfigWrapper @Inject constructor() { val isFollowedSitesSettingsEnabled = BuildConfig.ENABLE_FOLLOWED_SITES_SETTINGS val isWhatsNewFeatureEnabled = BuildConfig.ENABLE_WHATS_NEW_FEATURE - - val isMySiteTabsEnabled = BuildConfig.ENABLE_MY_SITE_DASHBOARD_TABS } From de0b66d4f0eefcf92b1a45121a40393a2d15f80a Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 15:31:08 +0530 Subject: [PATCH 08/23] =?UTF-8?q?=E2=86=91=20Updates:=20the=20padding=20an?= =?UTF-8?q?d=20spacing=20in=20Quick=20links?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WordPress/src/main/res/layout/quick_link_ribbon_list.xml | 3 ++- WordPress/src/main/res/values/dimens.xml | 5 ++--- WordPress/src/main/res/values/styles.xml | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/res/layout/quick_link_ribbon_list.xml b/WordPress/src/main/res/layout/quick_link_ribbon_list.xml index 1e1e3893ea9f..fd59b32646d1 100644 --- a/WordPress/src/main/res/layout/quick_link_ribbon_list.xml +++ b/WordPress/src/main/res/layout/quick_link_ribbon_list.xml @@ -5,7 +5,8 @@ style="@style/WordPress.CardView.Unelevated" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_margin="@dimen/margin_extra_large" + android:layout_marginHorizontal="@dimen/quick_link_ribbon_margin_horizontal" + android:layout_marginBottom="@dimen/quick_link_ribbon_margin_vertical" android:foreground="?attr/selectableItemBackground"> 16dp - 12dp - 16dp - 8dp + 16dp + 8dp 24dp 16sp 10dp diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 355950ad6b32..4759e624a441 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1673,10 +1673,6 @@ ?attr/wpColorOnSurfaceMedium @dimen/quick_link_ribbon_icon_padding @dimen/quick_link_ribbon_corner_radius - @dimen/quick_link_ribbon_padding_end - @dimen/quick_link_ribbon_padding_start - @dimen/quick_link_ribbon_padding_vertical - @dimen/quick_link_ribbon_padding_vertical san-serif 0 false From 2e7427dd7333c6e65dbe692ac6f6b9dc892b3ac6 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 15:43:35 +0530 Subject: [PATCH 09/23] + Adds: disable tint attribute --- .../java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt | 1 + .../cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt | 1 + .../cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt | 1 + 3 files changed, 3 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt index 6416310d8257..b0ab41459786 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt @@ -94,6 +94,7 @@ sealed class MySiteCardAndItem(open val type: Type, open val activeQuickStartIte data class QuickLinkRibbonItem( val label: UiString.UiStringRes, @DrawableRes val icon: Int, + val disableTint: Boolean = false, val onClick: ListItemInteraction, val showFocusPoint: Boolean = false, val listItemAction: ListItemAction diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt index ede54d923fe3..82aeb72a81aa 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt @@ -15,5 +15,6 @@ class QuickLinkRibbonItemViewHolder( quickLinkItem.setIconResource(item.icon) quickLinkItem.setOnClickListener { item.onClick.click() } quickLinkItemQuickStartFocusPoint.setVisibleOrGone(item.showFocusPoint) + if (item.disableTint) quickLinkItem.iconTint = null } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt index 1754060ec5b1..11e88ec8f2fb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt @@ -96,6 +96,7 @@ class QuickLinksItemViewModelSlice @Inject constructor( val activeQuickLinks = activeListItems.map { listItem -> MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem( icon = listItem.primaryIcon, + disableTint = listItem.disablePrimaryIconTint, label = (listItem.primaryText as UiString.UiStringRes), onClick = listItem.onClick, listItemAction = listItem.listItemAction, From 92d167e9d04a23f444a5a5e8a6b514161b9a2849 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 15:47:06 +0530 Subject: [PATCH 10/23] * Fixes: RTL for quick links --- WordPress/src/main/res/values/styles.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/res/values/styles.xml b/WordPress/src/main/res/values/styles.xml index 4759e624a441..ba8f23b0feb8 100644 --- a/WordPress/src/main/res/values/styles.xml +++ b/WordPress/src/main/res/values/styles.xml @@ -1678,7 +1678,7 @@ false ?attr/colorOnSurface @dimen/quick_link_ribbon_text_size - textStart + viewStart @color/on_surface_disabled_transparent_selector From dd2c3474078be702de2edfedefa7bd3acec20bc2 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 16:16:51 +0530 Subject: [PATCH 11/23] + Adds: Quick link build logic when there is a site change --- .../java/org/wordpress/android/ui/mysite/MySiteViewModel.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index c68dfbb9436d..524374dafffe 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -252,6 +252,7 @@ class MySiteViewModel @Inject constructor( val state: LiveData = selectedSiteRepository.siteSelected.switchMap { siteLocalId -> isSiteSelected = true + quickLinksItemViewModelSlice.onSiteChanged() resetShownTrackers() val result = MediatorLiveData() for (newSource in mySiteSourceManager.build(viewModelScope, siteLocalId)) { @@ -294,7 +295,6 @@ class MySiteViewModel @Inject constructor( } else { buildNoSiteState() } - bloggingPromptCardViewModelSlice.onSiteChanged(site?.id) dashboardCardPlansUtils.onSiteChanged(site?.id, state as? SiteSelected) From 593ecb11de3741761b541567d32518c03582ca61 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 16:20:04 +0530 Subject: [PATCH 12/23] + Adds: Quick link build logic when there is a site change --- .../cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt index 11e88ec8f2fb..14d44b1810e9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt @@ -201,4 +201,8 @@ class QuickLinksItemViewModelSlice @Inject constructor( activeTask == QuickStartStore.QuickStartExistingSiteTask.UPLOAD_MEDIA || activeTask == QuickStartStore.QuickStartNewSiteTask.ENABLE_POST_SHARING } + + fun onSiteChanged() { + buildQuickLinks() + } } From 2d138767585abaff5324c58185ced545f4ef7906 Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 16:32:51 +0530 Subject: [PATCH 13/23] + Adds: the logic for OnResume refresh of MySiteViewModel --- .../ui/mysite/BloggingPromptsCardTrackHelper.kt | 10 ++-------- .../android/ui/mysite/MySiteFragment.kt | 5 +++++ .../android/ui/mysite/MySiteViewModel.kt | 6 +++--- .../BloggingPromptCardViewModelSlice.kt | 5 ++--- .../cards/dashboard/plans/PlansCardUtils.kt | 17 ++++++----------- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/BloggingPromptsCardTrackHelper.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/BloggingPromptsCardTrackHelper.kt index cf6ef01c8116..6fa89ea3b74d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/BloggingPromptsCardTrackHelper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/BloggingPromptsCardTrackHelper.kt @@ -8,7 +8,6 @@ import kotlinx.coroutines.launch import org.wordpress.android.modules.BG_THREAD import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard import org.wordpress.android.ui.mysite.cards.dashboard.bloggingprompts.BloggingPromptsCardAnalyticsTracker -import org.wordpress.android.ui.mysite.tabs.MySiteTabType import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicReference import javax.inject.Inject @@ -63,13 +62,8 @@ class BloggingPromptsCardTrackHelper @Inject constructor( } } - fun onResume(currentTab: MySiteTabType) { - if (currentTab == MySiteTabType.DASHBOARD) { - onDashboardRefreshed() - } else { - // moved away from dashboard, no longer waiting to track - waitingToTrack.set(false) - } + fun onResume() { + onDashboardRefreshed() } fun onSiteChanged(siteId: Int?) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt index e4d5a2a9411a..eadc41ec501b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteFragment.kt @@ -178,6 +178,11 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment), } } + override fun onResume() { + super.onResume() + viewModel.onResume() + } + override fun onDestroyView() { super.onDestroyView() binding = null diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index 524374dafffe..3146d3a21d16 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -642,13 +642,13 @@ class MySiteViewModel @Inject constructor( quickLinksItemViewModelSlice.onRefresh() } - fun onResume(currentTab: MySiteTabType) { + fun onResume() { mySiteSourceManager.onResume(isSiteSelected) isSiteSelected = false checkAndShowJetpackFullPluginInstallOnboarding() checkAndShowQuickStartNotice() - bloggingPromptCardViewModelSlice.onResume(currentTab) - dashboardCardPlansUtils.onResume(currentTab, uiModel.value?.state as? SiteSelected) + bloggingPromptCardViewModelSlice.onResume() + dashboardCardPlansUtils.onResume(uiModel.value?.state as? SiteSelected) quickLinksItemViewModelSlice.onResume() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/bloggingprompts/BloggingPromptCardViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/bloggingprompts/BloggingPromptCardViewModelSlice.kt index b0bc375fd55f..f9515466a038 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/bloggingprompts/BloggingPromptCardViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/bloggingprompts/BloggingPromptCardViewModelSlice.kt @@ -17,7 +17,6 @@ import org.wordpress.android.ui.mysite.MySiteSourceManager import org.wordpress.android.ui.mysite.MySiteUiState import org.wordpress.android.ui.mysite.SelectedSiteRepository import org.wordpress.android.ui.mysite.SiteNavigationAction -import org.wordpress.android.ui.mysite.tabs.MySiteTabType import org.wordpress.android.ui.pages.SnackbarMessageHolder import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.ui.utils.UiString @@ -132,7 +131,7 @@ class BloggingPromptCardViewModelSlice @Inject constructor( bloggingPromptsCardTrackHelper.onSiteChanged(siteId) } - fun onResume(currentTab: MySiteTabType) { - bloggingPromptsCardTrackHelper.onResume(currentTab) + fun onResume() { + bloggingPromptsCardTrackHelper.onResume() } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/plans/PlansCardUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/plans/PlansCardUtils.kt index 2c97057c2700..62bb34bc979b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/plans/PlansCardUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/dashboard/plans/PlansCardUtils.kt @@ -10,7 +10,6 @@ import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.modules.BG_THREAD import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardPlansCard import org.wordpress.android.ui.mysite.MySiteViewModel.State.SiteSelected -import org.wordpress.android.ui.mysite.tabs.MySiteTabType import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.util.BuildConfigWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper @@ -52,8 +51,8 @@ class PlansCardUtils @Inject constructor( dashboardUpdateDebounceJob = scope.launch(bgDispatcher) { val isVisible = siteSelected ?.dashboardCardsAndItems - ?.any { - card -> card is DashboardPlansCard + ?.any { card -> + card is DashboardPlansCard } ?: false // add a delay (debouncing mechanism) @@ -71,13 +70,8 @@ class PlansCardUtils @Inject constructor( } } - fun onResume(currentTab: MySiteTabType, siteSelected: SiteSelected?) { - if (currentTab == MySiteTabType.DASHBOARD) { - onDashboardRefreshed(siteSelected) - } else { - // moved away from dashboard, no longer waiting to track - waitingToTrack.set(false) - } + fun onResume(siteSelected: SiteSelected?) { + onDashboardRefreshed(siteSelected) } fun onSiteChanged(siteId: Int?, siteSelected: SiteSelected?) { @@ -100,6 +94,7 @@ class PlansCardUtils @Inject constructor( mapOf(POSITION_INDEX to positionIndex(siteSelected)) ) } + fun trackCardHiddenByUser(siteSelected: SiteSelected?) { analyticsTrackerWrapper.track( AnalyticsTracker.Stat.DASHBOARD_CARD_PLANS_HIDDEN, @@ -110,7 +105,7 @@ class PlansCardUtils @Inject constructor( private fun trackCardShown(positionIndex: Int) { analyticsTrackerWrapper.track( AnalyticsTracker.Stat.DASHBOARD_CARD_PLANS_SHOWN, - mapOf(POSITION_INDEX to positionIndex) + mapOf(POSITION_INDEX to positionIndex) ) } From 08a7986493c8be65ab0a95c74d9dc86e74c6229a Mon Sep 17 00:00:00 2001 From: Ajesh R Pai Date: Fri, 29 Sep 2023 17:07:24 +0530 Subject: [PATCH 14/23] =?UTF-8?q?=E2=86=91=20Updates:=20the=20naming=20of?= =?UTF-8?q?=20quick=20link=20ribbon=20to=20item?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../android/ui/mysite/MySiteAdapter.kt | 30 +++++++++---------- .../ui/mysite/MySiteAdapterDiffCallback.kt | 30 +++++++++---------- .../android/ui/mysite/MySiteCardAndItem.kt | 6 ++-- .../android/ui/mysite/MySiteViewModel.kt | 8 ++--- .../QuickLinkRibbonViewHolder.kt | 26 ++++++++-------- .../QuickLinksItemAdapter.kt} | 20 ++++++------- .../QuickLinksItemViewHolder.kt} | 12 ++++---- .../QuickLinksItemViewModelSlice.kt | 28 ++++++++--------- .../ui/quickstart/QuickStartMySitePrompts.kt | 6 ++-- ...nk_ribbon_item.xml => quick_link_item.xml} | 2 +- ...k_ribbon_list.xml => quick_links_list.xml} | 2 +- WordPress/src/main/res/values/styles.xml | 2 +- .../android/ui/mysite/MySiteViewModelTest.kt | 2 +- 13 files changed, 87 insertions(+), 87 deletions(-) rename WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/{quicklinksribbon => quicklinksitem}/QuickLinkRibbonViewHolder.kt (52%) rename WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/{quicklinksribbon/QuickLinkRibbonItemAdapter.kt => quicklinksitem/QuickLinksItemAdapter.kt} (70%) rename WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/{quicklinksribbon/QuickLinkRibbonItemViewHolder.kt => quicklinksitem/QuickLinksItemViewHolder.kt} (61%) rename WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/{quicklinksribbon => quicklinksitem}/QuickLinksItemViewModelSlice.kt (89%) rename WordPress/src/main/res/layout/{quick_link_ribbon_item.xml => quick_link_item.xml} (96%) rename WordPress/src/main/res/layout/{quick_link_ribbon_list.xml => quick_links_list.xml} (95%) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapter.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapter.kt index 1e925ea3fba8..7c9bba701b21 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapter.kt @@ -5,13 +5,24 @@ import android.view.ViewGroup import androidx.recyclerview.widget.ListAdapter import org.wordpress.android.fluxc.store.AccountStore import org.wordpress.android.ui.main.utils.MeGravatarLoader +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ActivityCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.BlazeCampaignsCardModel +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.PromoteWithBlazeCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard.BloggingPromptCardWithData +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardPlansCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainRegistrationCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainTransferCardModel +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorWithinCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackFeatureCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackInstallFullPluginCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackSwitchMenu -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinkRibbon -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickStartCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PagesCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PersonalizeCardModel +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PostCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinksItem +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickStartCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.TodaysStatsCard.TodaysStatsCardWithData import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.CategoryEmptyHeaderItem import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.CategoryHeaderItem import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.InfoItem @@ -36,7 +47,7 @@ import org.wordpress.android.ui.mysite.cards.jetpackfeature.SwitchToJetpackMenuC import org.wordpress.android.ui.mysite.cards.jpfullplugininstall.JetpackInstallFullPluginCardViewHolder import org.wordpress.android.ui.mysite.cards.nocards.NoCardsMessageViewHolder import org.wordpress.android.ui.mysite.cards.personalize.PersonalizeCardViewHolder -import org.wordpress.android.ui.mysite.cards.quicklinksribbon.QuickLinkRibbonViewHolder +import org.wordpress.android.ui.mysite.cards.quicklinksitem.QuickLinkRibbonViewHolder import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartCardViewHolder import org.wordpress.android.ui.mysite.items.categoryheader.MySiteCategoryItemEmptyViewHolder import org.wordpress.android.ui.mysite.items.categoryheader.MySiteCategoryItemViewHolder @@ -47,17 +58,6 @@ import org.wordpress.android.ui.mysite.jetpackbadge.MySiteJetpackBadgeViewHolder import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.util.HtmlCompatWrapper import org.wordpress.android.util.image.ImageManager -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ActivityCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.BlazeCampaignsCardModel -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.PromoteWithBlazeCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard.BloggingPromptCardWithData -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardPlansCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainTransferCardModel -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorWithinCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PagesCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PostCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.TodaysStatsCard.TodaysStatsCardWithData @Suppress("LongParameterList") class MySiteAdapter( @@ -127,7 +127,7 @@ class MySiteAdapter( @Suppress("ComplexMethod") override fun onBindViewHolder(holder: MySiteCardAndItemViewHolder<*>, position: Int) { when (holder) { - is QuickLinkRibbonViewHolder -> holder.bind(getItem(position) as QuickLinkRibbon) + is QuickLinkRibbonViewHolder -> holder.bind(getItem(position) as QuickLinksItem) is DomainRegistrationViewHolder -> holder.bind(getItem(position) as DomainRegistrationCard) is QuickStartCardViewHolder -> holder.bind(getItem(position) as QuickStartCard) is MySiteInfoItemViewHolder -> holder.bind(getItem(position) as InfoItem) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapterDiffCallback.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapterDiffCallback.kt index 8c38a8b72624..85c9f678da87 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapterDiffCallback.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteAdapterDiffCallback.kt @@ -1,36 +1,36 @@ package org.wordpress.android.ui.mysite import androidx.recyclerview.widget.DiffUtil +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ActivityCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.BlazeCampaignsCardModel +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.PromoteWithBlazeCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard.BloggingPromptCardWithData +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardPlansCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainRegistrationCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainTransferCardModel +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorWithinCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackFeatureCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackInstallFullPluginCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinkRibbon -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickStartCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.JetpackSwitchMenu +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PagesCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PersonalizeCardModel -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.CategoryHeaderItem +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PostCard.PostCardWithPostItems +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinksItem +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickStartCard +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.TodaysStatsCard.TodaysStatsCardWithData import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.CategoryEmptyHeaderItem +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.CategoryHeaderItem import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.InfoItem import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.ListItem import org.wordpress.android.ui.mysite.MySiteCardAndItem.Item.SingleActionCard import org.wordpress.android.ui.mysite.MySiteCardAndItem.JetpackBadge -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ActivityCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DomainTransferCardModel -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.DashboardPlansCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.PromoteWithBlazeCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BlazeCard.BlazeCampaignsCardModel -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.BloggingPromptCard.BloggingPromptCardWithData -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.ErrorWithinCard -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PostCard.PostCardWithPostItems -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.TodaysStatsCard.TodaysStatsCardWithData -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.PagesCard @Suppress("ComplexMethod") object MySiteAdapterDiffCallback : DiffUtil.ItemCallback() { override fun areItemsTheSame(oldItem: MySiteCardAndItem, updatedItem: MySiteCardAndItem): Boolean { return oldItem.type == updatedItem.type && when { - oldItem is QuickLinkRibbon && updatedItem is QuickLinkRibbon -> true + oldItem is QuickLinksItem && updatedItem is QuickLinksItem -> true oldItem is DomainRegistrationCard && updatedItem is DomainRegistrationCard -> true oldItem is QuickStartCard && updatedItem is QuickStartCard -> true oldItem is InfoItem && updatedItem is InfoItem -> oldItem.title == updatedItem.title diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt index b0ab41459786..c2c7d7ba5174 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteCardAndItem.kt @@ -84,14 +84,14 @@ sealed class MySiteCardAndItem(open val type: Type, open val activeQuickStartIte override val type: Type, override val activeQuickStartItem: Boolean = false ) : MySiteCardAndItem(type, activeQuickStartItem) { - data class QuickLinkRibbon( - val quickLinkRibbonItems: List, + data class QuickLinksItem( + val quickLinkItems: List, val showMoreFocusPoint : Boolean = false ) : Card( QUICK_LINK_RIBBON, activeQuickStartItem = showMoreFocusPoint ) { - data class QuickLinkRibbonItem( + data class QuickLinkItem( val label: UiString.UiStringRes, @DrawableRes val icon: Int, val disableTint: Boolean = false, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt index 3146d3a21d16..4f3be11959c0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/MySiteViewModel.kt @@ -77,7 +77,7 @@ import org.wordpress.android.ui.mysite.cards.jpfullplugininstall.JetpackInstallF import org.wordpress.android.ui.mysite.cards.nocards.NoCardsMessageViewModelSlice import org.wordpress.android.ui.mysite.cards.personalize.PersonalizeCardBuilder import org.wordpress.android.ui.mysite.cards.personalize.PersonalizeCardViewModelSlice -import org.wordpress.android.ui.mysite.cards.quicklinksribbon.QuickLinksItemViewModelSlice +import org.wordpress.android.ui.mysite.cards.quicklinksitem.QuickLinksItemViewModelSlice import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartCardBuilder import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartCardType import org.wordpress.android.ui.mysite.cards.quickstart.QuickStartRepository @@ -180,7 +180,7 @@ class MySiteViewModel @Inject constructor( as they're already built on site select. */ private var isSiteSelected = false - val quickLinks: LiveData = merge( + val quickLinks: LiveData = merge( quickLinksItemViewModelSlice.uiState, quickStartRepository.activeTask ) { quickLinks, activeTask -> @@ -333,7 +333,7 @@ class MySiteViewModel @Inject constructor( cardsUpdate: CardsUpdate?, bloggingPromptUpdate: BloggingPromptUpdate?, blazeCardUpdate: BlazeCardUpdate?, - quickLinks: MySiteCardAndItem.Card.QuickLinkRibbon? = null + quickLinks: MySiteCardAndItem.Card.QuickLinksItem? = null ): SiteSelected { val siteItems = buildSiteSelectedState( site, @@ -388,7 +388,7 @@ class MySiteViewModel @Inject constructor( cardsUpdate: CardsUpdate?, bloggingPromptUpdate: BloggingPromptUpdate?, blazeCardUpdate: BlazeCardUpdate?, - quickLinks: MySiteCardAndItem.Card.QuickLinkRibbon? + quickLinks: MySiteCardAndItem.Card.QuickLinksItem? ): Map> { val infoItem = mySiteInfoItemBuilder.build( InfoItemBuilderParams( diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinkRibbonViewHolder.kt similarity index 52% rename from WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonViewHolder.kt rename to WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinkRibbonViewHolder.kt index b27ba14367c5..b8f7f41a6e26 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinkRibbonViewHolder.kt @@ -1,41 +1,41 @@ -package org.wordpress.android.ui.mysite.cards.quicklinksribbon +package org.wordpress.android.ui.mysite.cards.quicklinksitem import android.view.ViewGroup import androidx.recyclerview.widget.DividerItemDecoration import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.google.android.material.divider.MaterialDividerItemDecoration -import org.wordpress.android.databinding.QuickLinkRibbonListBinding -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinkRibbon +import org.wordpress.android.databinding.QuickLinksListBinding +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinksItem import org.wordpress.android.ui.mysite.MySiteCardAndItemViewHolder import org.wordpress.android.util.extensions.viewBinding class QuickLinkRibbonViewHolder( parent: ViewGroup -) : MySiteCardAndItemViewHolder( - parent.viewBinding(QuickLinkRibbonListBinding::inflate) +) : MySiteCardAndItemViewHolder( + parent.viewBinding(QuickLinksListBinding::inflate) ) { init { - with(binding.quickLinkRibbonItemList) { + with(binding.quickLinksItemList) { if (adapter == null) { layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - adapter = QuickLinkRibbonItemAdapter() + adapter = QuickLinksItemAdapter() } } } - fun bind(quickLinkRibbon: QuickLinkRibbon) = with(binding) { - quickLinkRibbonItemList.addItemDecoration( + fun bind(quickLinksItem: QuickLinksItem) = with(binding) { + quickLinksItemList.addItemDecoration( MaterialDividerItemDecoration( - quickLinkRibbonItemList.context, + quickLinksItemList.context, DividerItemDecoration.VERTICAL ).apply { isLastItemDecorated = false } ) - (quickLinkRibbonItemList.adapter as QuickLinkRibbonItemAdapter).update(quickLinkRibbon.quickLinkRibbonItems) - if (quickLinkRibbon.showMoreFocusPoint) { - quickLinkRibbonItemList.smoothScrollToPosition(quickLinkRibbonItemList.adapter!!.itemCount - 1) + (quickLinksItemList.adapter as QuickLinksItemAdapter).update(quickLinksItem.quickLinkItems) + if (quickLinksItem.showMoreFocusPoint) { + quickLinksItemList.smoothScrollToPosition(quickLinksItemList.adapter!!.itemCount - 1) } } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemAdapter.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemAdapter.kt similarity index 70% rename from WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemAdapter.kt rename to WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemAdapter.kt index 6c670c17d09e..d1c609556736 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemAdapter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemAdapter.kt @@ -1,27 +1,27 @@ -package org.wordpress.android.ui.mysite.cards.quicklinksribbon +package org.wordpress.android.ui.mysite.cards.quicklinksitem import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.DiffUtil.Callback import androidx.recyclerview.widget.RecyclerView.Adapter -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinksItem.QuickLinkItem -class QuickLinkRibbonItemAdapter : Adapter() { - private val items = mutableListOf() +class QuickLinksItemAdapter : Adapter() { + private val items = mutableListOf() override fun onCreateViewHolder( parent: ViewGroup, viewType: Int - ): QuickLinkRibbonItemViewHolder { - return QuickLinkRibbonItemViewHolder(parent) + ): QuickLinksItemViewHolder { + return QuickLinksItemViewHolder(parent) } override fun getItemCount(): Int = items.size - override fun onBindViewHolder(holder: QuickLinkRibbonItemViewHolder, position: Int) { + override fun onBindViewHolder(holder: QuickLinksItemViewHolder, position: Int) { holder.onBind(items[position]) } - fun update(newItems: List) { + fun update(newItems: List) { val diffResult = DiffUtil.calculateDiff(InterestDiffUtil(items, newItems)) items.clear() items.addAll(newItems) @@ -29,8 +29,8 @@ class QuickLinkRibbonItemAdapter : Adapter() { } class InterestDiffUtil( - private val oldList: List, - private val newList: List + private val oldList: List, + private val newList: List ) : Callback() { override fun areItemsTheSame(oldItemPosition: Int, newItemPosition: Int): Boolean { val newItem = newList[newItemPosition] diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewHolder.kt similarity index 61% rename from WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt rename to WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewHolder.kt index 82aeb72a81aa..429aa4ec8f8c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinkRibbonItemViewHolder.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewHolder.kt @@ -1,16 +1,16 @@ -package org.wordpress.android.ui.mysite.cards.quicklinksribbon +package org.wordpress.android.ui.mysite.cards.quicklinksitem import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView -import org.wordpress.android.databinding.QuickLinkRibbonItemBinding -import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem +import org.wordpress.android.databinding.QuickLinkItemBinding +import org.wordpress.android.ui.mysite.MySiteCardAndItem.Card.QuickLinksItem.QuickLinkItem import org.wordpress.android.util.extensions.viewBinding -class QuickLinkRibbonItemViewHolder( +class QuickLinksItemViewHolder( parent: ViewGroup, - private val binding: QuickLinkRibbonItemBinding = parent.viewBinding(QuickLinkRibbonItemBinding::inflate) + private val binding: QuickLinkItemBinding = parent.viewBinding(QuickLinkItemBinding::inflate) ) : RecyclerView.ViewHolder(binding.root) { - fun onBind(item: QuickLinkRibbonItem) = with(binding) { + fun onBind(item: QuickLinkItem) = with(binding) { quickLinkItem.setText(item.label.stringRes) quickLinkItem.setIconResource(item.icon) quickLinkItem.setOnClickListener { item.onClick.click() } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewModelSlice.kt similarity index 89% rename from WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt rename to WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewModelSlice.kt index 14d44b1810e9..e6cf1156814e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksribbon/QuickLinksItemViewModelSlice.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/mysite/cards/quicklinksitem/QuickLinksItemViewModelSlice.kt @@ -1,4 +1,4 @@ -package org.wordpress.android.ui.mysite.cards.quicklinksribbon +package org.wordpress.android.ui.mysite.cards.quicklinksitem import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData @@ -50,8 +50,8 @@ class QuickLinksItemViewModelSlice @Inject constructor( private val _onSnackbarMessage = MutableLiveData>() val onSnackbarMessage = _onSnackbarMessage - private val _uiState = MutableLiveData() - val uiState: LiveData = _uiState + private val _uiState = MutableLiveData() + val uiState: LiveData = _uiState fun start() { buildQuickLinks() @@ -89,12 +89,12 @@ class QuickLinksItemViewModelSlice @Inject constructor( private fun convertToQuickLinkRibbonItem( listItems: List, - ): MySiteCardAndItem.Card.QuickLinkRibbon { + ): MySiteCardAndItem.Card.QuickLinksItem { val siteId = selectedSiteRepository.getSelectedSite()!!.siteId val activeListItems = listItems.filterIsInstance(MySiteCardAndItem.Item.ListItem::class.java) .filter { isActiveQuickLink(it.listItemAction, siteId = siteId) } val activeQuickLinks = activeListItems.map { listItem -> - MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem( + MySiteCardAndItem.Card.QuickLinksItem.QuickLinkItem( icon = listItem.primaryIcon, disableTint = listItem.disablePrimaryIconTint, label = (listItem.primaryText as UiString.UiStringRes), @@ -102,7 +102,7 @@ class QuickLinksItemViewModelSlice @Inject constructor( listItemAction = listItem.listItemAction, ) } - val moreQuickLink = MySiteCardAndItem.Card.QuickLinkRibbon.QuickLinkRibbonItem( + val moreQuickLink = MySiteCardAndItem.Card.QuickLinksItem.QuickLinkItem( icon = R.drawable.ic_more_horiz_white_24dp, label = UiString.UiStringRes(R.string.more), onClick = ListItemInteraction.create( @@ -111,8 +111,8 @@ class QuickLinksItemViewModelSlice @Inject constructor( ), listItemAction = ListItemAction.MORE ) - return MySiteCardAndItem.Card.QuickLinkRibbon( - quickLinkRibbonItems = activeQuickLinks + moreQuickLink + return MySiteCardAndItem.Card.QuickLinksItem( + quickLinkItems = activeQuickLinks + moreQuickLink ) } @@ -160,15 +160,15 @@ class QuickLinksItemViewModelSlice @Inject constructor( } fun updateToShowMoreFocusPointIfNeeded( - quickLinks: MySiteCardAndItem.Card.QuickLinkRibbon, + quickLinks: MySiteCardAndItem.Card.QuickLinksItem, activeTask: QuickStartStore.QuickStartTask - ): MySiteCardAndItem.Card.QuickLinkRibbon { - val updatedQuickLinks = if (shouldShowMoreFocusPoint(quickLinks.quickLinkRibbonItems, activeTask)) { - val quickLinkItems = quickLinks.quickLinkRibbonItems.toMutableList() + ): MySiteCardAndItem.Card.QuickLinksItem { + val updatedQuickLinks = if (shouldShowMoreFocusPoint(quickLinks.quickLinkItems, activeTask)) { + val quickLinkItems = quickLinks.quickLinkItems.toMutableList() val lastItem = quickLinkItems.last().copy(showFocusPoint = true) quickLinkItems.removeLast() quickLinkItems.add(lastItem) - quickLinks.copy(quickLinkRibbonItems = quickLinkItems, showMoreFocusPoint = true) + quickLinks.copy(quickLinkItems = quickLinkItems, showMoreFocusPoint = true) } else { quickLinks } @@ -176,7 +176,7 @@ class QuickLinksItemViewModelSlice @Inject constructor( } private fun shouldShowMoreFocusPoint( - activeShortcuts: List, + activeShortcuts: List, activeTask: QuickStartStore.QuickStartTask? ): Boolean { if (activeTask == null) return false diff --git a/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartMySitePrompts.kt b/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartMySitePrompts.kt index 454dd5ccf604..5861be66f0f4 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartMySitePrompts.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/quickstart/QuickStartMySitePrompts.kt @@ -62,14 +62,14 @@ enum class QuickStartMySitePrompts constructor( CHECK_STATS( QuickStartStore.QUICK_START_CHECK_STATS_LABEL, -1, - R.id.quick_link_ribbon_item_list, + R.id.quick_links_item_list, R.string.quick_start_dialog_check_stats_message_short, R.drawable.ic_stats_alt_white_24dp ), REVIEW_PAGES( QuickStartStore.QUICK_START_REVIEW_PAGES_LABEL, -1, - R.id.quick_link_ribbon_item_list, + R.id.quick_links_item_list, R.string.quick_start_dialog_review_pages_message_short, R.drawable.ic_pages_white_24dp ), @@ -83,7 +83,7 @@ enum class QuickStartMySitePrompts constructor( UPLOAD_MEDIA( QuickStartStore.QUICK_START_UPLOAD_MEDIA_LABEL, -1, - R.id.quick_link_ribbon_item_list, + R.id.quick_links_item_list, R.string.quick_start_dialog_upload_media_message, R.drawable.ic_media_white_24dp ); diff --git a/WordPress/src/main/res/layout/quick_link_ribbon_item.xml b/WordPress/src/main/res/layout/quick_link_item.xml similarity index 96% rename from WordPress/src/main/res/layout/quick_link_ribbon_item.xml rename to WordPress/src/main/res/layout/quick_link_item.xml index 7309688aac78..37c92f925ed9 100644 --- a/WordPress/src/main/res/layout/quick_link_ribbon_item.xml +++ b/WordPress/src/main/res/layout/quick_link_item.xml @@ -7,7 +7,7 @@ @dimen/material_emphasis_high_type -