diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 03965e2df258..6fdc884a0053 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -147,7 +147,7 @@ android { buildConfigField "boolean", "READER_IMPROVEMENTS", "false" buildConfigField "boolean", "BLOGANUARY_DASHBOARD_NUDGE", "false" buildConfigField "boolean", "DYNAMIC_DASHBOARD_CARDS", "false" - buildConfigField "boolean", "STATS_TRAFFIC_TAB", "false" + buildConfigField "boolean", "STATS_TRAFFIC_SUBSCRIBERS_TAB", "false" buildConfigField "boolean", "READER_DISCOVER_NEW_ENDPOINT", "false" buildConfigField "boolean", "READER_READING_PREFERENCES", "false" buildConfigField "boolean", "READER_READING_PREFERENCES_FEEDBACK", "false" diff --git a/WordPress/src/androidTest/resources/new-stats-feature-response.json b/WordPress/src/androidTest/resources/new-stats-feature-response.json index 6caeb0a839bd..07567a1926ac 100644 --- a/WordPress/src/androidTest/resources/new-stats-feature-response.json +++ b/WordPress/src/androidTest/resources/new-stats-feature-response.json @@ -1,3 +1,3 @@ { - "stats_traffic_tab": true + "stats_traffic_subscribers_tab": true } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsFragment.kt index 0bd8572cf639..82bf03abfad1 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsFragment.kt @@ -45,7 +45,7 @@ import org.wordpress.android.util.JetpackBrandingUtils import org.wordpress.android.models.JetpackPoweredScreen import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.TRAFFIC import org.wordpress.android.util.WPSwipeToRefreshHelper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.util.helpers.SwipeToRefreshHelper import org.wordpress.android.viewmodel.observeEvent import org.wordpress.android.widgets.WPSnackbar @@ -64,7 +64,7 @@ class StatsFragment : Fragment(R.layout.stats_fragment), ScrollableViewInitializ lateinit var jetpackBrandingUtils: JetpackBrandingUtils @Inject - lateinit var statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var mStatsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private val viewModel: StatsViewModel by activityViewModels() private lateinit var swipeToRefreshHelper: SwipeToRefreshHelper @@ -99,7 +99,7 @@ class StatsFragment : Fragment(R.layout.stats_fragment), ScrollableViewInitializ } private fun StatsFragmentBinding.initializeViews() { - statsTrafficTabEnabled = statsTrafficTabFeatureConfig.isEnabled() + statsTrafficTabEnabled = mStatsTrafficSubscribersTabFeatureConfig.isEnabled() val adapter = StatsPagerAdapter(this@StatsFragment) statsPager.adapter = adapter diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsModule.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsModule.kt index 9bad7e09d488..0e8a37e02c07 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsModule.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsModule.kt @@ -65,7 +65,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.insights.usecases.V import org.wordpress.android.ui.stats.refresh.lists.sections.traffic.TrafficOverviewUseCase.TrafficOverviewUseCaseFactory import org.wordpress.android.ui.stats.refresh.utils.SelectedTrafficGranularityManager import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Named import javax.inject.Singleton @@ -129,7 +129,7 @@ class StatsModule { actionCardGrowUseCase: ActionCardGrowUseCase, actionCardReminderUseCase: ActionCardReminderUseCase, actionCardScheduleUseCase: ActionCardScheduleUseCase, - trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ): List<@JvmSuppressWildcards BaseStatsUseCase<*, *>> { val useCases = mutableListOf>() if (BuildConfig.IS_JETPACK_APP) { @@ -144,7 +144,7 @@ class StatsModule { useCases.add(followerTotalsUseCase) } - if (!trafficTabFeatureConfig.isEnabled()) { + if (!trafficSubscribersTabFeatureConfig.isEnabled()) { useCases.add(todayStatsUseCase) } @@ -452,9 +452,9 @@ class StatsModule { @Named(WEEK_STATS_USE_CASE) weekStatsUseCase: BaseListUseCase, @Named(MONTH_STATS_USE_CASE) monthStatsUseCase: BaseListUseCase, @Named(YEAR_STATS_USE_CASE) yearStatsUseCase: BaseListUseCase, - trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ): Map { - return if (trafficTabFeatureConfig.isEnabled()) { + return if (trafficSubscribersTabFeatureConfig.isEnabled()) { mapOf( StatsSection.TRAFFIC to trafficUseCase, StatsSection.INSIGHTS to insightsUseCase diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllFragment.kt index 056f78e59d12..93810c51be53 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewAllFragment.kt @@ -35,7 +35,7 @@ import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider import org.wordpress.android.ui.stats.refresh.utils.drawDateSelector import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.util.WPSwipeToRefreshHelper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.util.extensions.getParcelableCompat import org.wordpress.android.util.extensions.getParcelableExtraCompat import org.wordpress.android.util.extensions.getSerializableCompat @@ -64,7 +64,7 @@ class StatsViewAllFragment : Fragment(R.layout.stats_view_all_fragment) { lateinit var uiHelpers: UiHelpers @Inject - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private lateinit var viewModel: StatsViewAllViewModel private lateinit var swipeToRefreshHelper: SwipeToRefreshHelper @@ -288,7 +288,7 @@ class StatsViewAllFragment : Fragment(R.layout.stats_view_all_fragment) { private fun loadData(recyclerView: RecyclerView, data: List) { val adapter: BlockListAdapter if (recyclerView.adapter == null) { - adapter = BlockListAdapter(imageManager, trafficTabFeatureConfig.isEnabled()) + adapter = BlockListAdapter(imageManager, trafficSubscribersTabFeatureConfig.isEnabled()) recyclerView.adapter = adapter } else { adapter = recyclerView.adapter as BlockListAdapter diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt index dc2053d61f74..b43c0c590952 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/StatsViewModel.kt @@ -55,7 +55,7 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.JetpackBrandingUtils import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.util.extensions.getSerializableExtraCompat import org.wordpress.android.util.mapNullable import org.wordpress.android.util.mergeNotNull @@ -82,7 +82,7 @@ class StatsViewModel private val notificationsTracker: SystemNotificationsTracker, private val jetpackBrandingUtils: JetpackBrandingUtils, private val jetpackFeatureRemovalOverlayUtil: JetpackFeatureRemovalOverlayUtil, - private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) : ScopedViewModel(mainDispatcher) { private val _isRefreshing = MutableLiveData() val isRefreshing: LiveData = _isRefreshing @@ -149,7 +149,7 @@ class StatsViewModel } private fun getInitialTimeFrame(timeframe: StatsTimeframe?, launchedFrom: StatsLaunchedFrom?): StatsSection? { - if (statsTrafficTabFeatureConfig.isEnabled() && launchedFrom == StatsLaunchedFrom.LINK) { + if (statsTrafficSubscribersTabFeatureConfig.isEnabled() && launchedFrom == StatsLaunchedFrom.LINK) { setupDeeplinkForTrafficTab(timeframe) } @@ -200,7 +200,7 @@ class StatsViewModel statsSectionManager.setSelectedSection(it) val trafficGranularity = it.toStatsGranularity() - if (statsTrafficTabFeatureConfig.isEnabled() && trafficGranularity != null) { + if (statsTrafficSubscribersTabFeatureConfig.isEnabled() && trafficGranularity != null) { selectedTrafficGranularityManager.setSelectedTrafficGranularity(trafficGranularity) } } @@ -209,7 +209,7 @@ class StatsViewModel selectedTrafficGranularityManager.setSelectedTrafficGranularity(it) } } - updateSelectedSectionByTrafficTabFeatureConfig() + updateSelectedSectionByTrafficSubscribersTabFeatureConfig() trackSectionSelected(statsSectionManager.getSelectedSection()) val initialGranularity = granularity ?: initialSection?.toStatsGranularity() @@ -252,8 +252,8 @@ class StatsViewModel showJetpackOverlay() } - private fun updateSelectedSectionByTrafficTabFeatureConfig() { - if (statsTrafficTabFeatureConfig.isEnabled()) { + private fun updateSelectedSectionByTrafficSubscribersTabFeatureConfig() { + if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) { val selectedSection = statsSectionManager.getSelectedSection() val isSelectedSectionRemoved = selectedSection == StatsSection.DAYS || selectedSection == StatsSection.WEEKS || @@ -261,7 +261,7 @@ class StatsViewModel selectedSection == StatsSection.YEARS if (isSelectedSectionRemoved) { - // statsTrafficTabFeatureConfig has just been enabled. Update the cached selected section. + // statsTrafficSubscribersTabFeatureConfig has just been enabled. Update the cached selected section. statsSectionManager.setSelectedSection(StatsSection.TRAFFIC) } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListFragment.kt index 2b745d8c3fc2..f692f3de906f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/StatsListFragment.kt @@ -34,7 +34,7 @@ import org.wordpress.android.ui.stats.refresh.utils.StatsDateFormatter import org.wordpress.android.ui.stats.refresh.utils.StatsNavigator import org.wordpress.android.ui.stats.refresh.utils.drawDateSelector import org.wordpress.android.ui.stats.refresh.utils.toNameResource -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.util.extensions.getParcelableCompat import org.wordpress.android.util.extensions.getSerializableCompat import org.wordpress.android.util.extensions.getSerializableExtraCompat @@ -58,7 +58,7 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) { lateinit var navigator: StatsNavigator @Inject - lateinit var statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig @Inject lateinit var selectedTrafficGranularityManager: SelectedTrafficGranularityManager @@ -155,7 +155,7 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) { } }) - if (statsTrafficTabFeatureConfig.isEnabled()) { + if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) { dateSelector.granularitySpinner.adapter = ArrayAdapter( requireContext(), R.layout.filter_spinner_item, @@ -332,7 +332,7 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) { private fun StatsListFragmentBinding.updateInsights(statsState: List) { val adapter: StatsBlockAdapter if (recyclerView.adapter == null) { - adapter = StatsBlockAdapter(imageManager, statsTrafficTabFeatureConfig.isEnabled()) + adapter = StatsBlockAdapter(imageManager, statsTrafficSubscribersTabFeatureConfig.isEnabled()) recyclerView.adapter = adapter } else { adapter = recyclerView.adapter as StatsBlockAdapter diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapper.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapper.kt index d0f9ecfe1c45..eaec3ddabb09 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapper.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapper.kt @@ -32,7 +32,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status.ADDED import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status.REMOVED import org.wordpress.android.ui.utils.ListItemInteraction -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject import javax.inject.Named @@ -52,13 +52,13 @@ private val GENERAL_INSIGHTS = mutableListOf( class InsightsManagementMapper @Inject constructor( @Named(BG_THREAD) private val bgDispatcher: CoroutineDispatcher, - private val trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) { suspend fun buildUIModel(addedTypes: Set, onClick: (InsightType) -> Unit) = withContext(bgDispatcher) { val insightListItems = mutableListOf() insightListItems += Header(R.string.stats_insights_management_general) - if (!trafficTabFeatureConfig.isEnabled() && !GENERAL_INSIGHTS.contains(TODAY_STATS)) { + if (!trafficSubscribersTabFeatureConfig.isEnabled() && !GENERAL_INSIGHTS.contains(TODAY_STATS)) { GENERAL_INSIGHTS.add(TODAY_STATS) } if (!GENERAL_INSIGHTS.contains(VIEWS_AND_VISITORS)) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt index 4cc9f497e432..bae6db22493d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/WidgetBlockListProvider.kt @@ -18,7 +18,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.today.TodayWidgetBloc import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode import org.wordpress.android.ui.stats.refresh.lists.widget.weeks.WeekWidgetBlockListViewModel import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject class WidgetBlockListProvider( @@ -27,7 +27,7 @@ class WidgetBlockListProvider( intent: Intent ) : RemoteViewsFactory { @Inject - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private val colorMode: Color = intent.getColorMode() private val siteId: Int = intent.getIntExtra(SITE_ID_KEY, -1) @@ -69,12 +69,16 @@ class WidgetBlockListProvider( rv.setTextViewText(R.id.start_block_value, uiModel.startValue) rv.setTextViewText(R.id.end_block_title, uiModel.endKey) rv.setTextViewText(R.id.end_block_value, uiModel.endValue) - val timeframe = if (trafficTabFeatureConfig.isEnabled()) StatsTimeframe.TRAFFIC else uiModel.targetTimeframe + val timeframe = if (trafficSubscribersTabFeatureConfig.isEnabled()) { + StatsTimeframe.TRAFFIC + } else { + uiModel.targetTimeframe + } val intent = Intent() intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.putExtra(WordPress.LOCAL_SITE_ID, uiModel.localSiteId) intent.putExtra(StatsActivity.ARG_DESIRED_TIMEFRAME, timeframe) - if (trafficTabFeatureConfig.isEnabled()) { + if (trafficSubscribersTabFeatureConfig.isEnabled()) { intent.putExtra(StatsActivity.ARG_GRANULARITY, getGranularity()) } intent.putExtra(StatsActivity.ARG_LAUNCHED_FROM, StatsLaunchedFrom.WIDGET) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/MinifiedWidgetUpdater.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/MinifiedWidgetUpdater.kt index 66a38921d125..3c111a21a8e6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/MinifiedWidgetUpdater.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/minified/MinifiedWidgetUpdater.kt @@ -34,7 +34,7 @@ import org.wordpress.android.ui.stats.refresh.utils.StatsUtils import org.wordpress.android.ui.stats.refresh.utils.trackMinifiedWidget import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import javax.inject.Inject import javax.inject.Named @@ -51,7 +51,7 @@ class MinifiedWidgetUpdater private val todayInsightsStore: TodayInsightsStore, private val widgetUtils: WidgetUtils, private val analyticsTrackerWrapper: AnalyticsTrackerWrapper, - private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) : WidgetUpdater { private val coroutineScope = CoroutineScope(defaultDispatcher) override fun updateAppWidget( @@ -79,8 +79,8 @@ class MinifiedWidgetUpdater views.setViewVisibility(R.id.widget_site_icon, View.VISIBLE) views.setViewVisibility(R.id.widget_retry_button, View.GONE) - val timeframe = if (statsTrafficTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS - val granularity = if (statsTrafficTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null + val timeframe = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS + val granularity = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null views.setOnClickPendingIntent( R.id.widget_container, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModel.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModel.kt index a2a4bdafe9c7..9771e86a3958 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModel.kt @@ -13,7 +13,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.WidgetBlockListProvid import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.utils.MILLION import org.wordpress.android.ui.stats.refresh.utils.StatsUtils -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import javax.inject.Inject @@ -25,7 +25,7 @@ class TodayWidgetBlockListViewModel private val todayWidgetUpdater: TodayWidgetUpdater, private val appPrefsWrapper: AppPrefsWrapper, private val statsUtils: StatsUtils, - private val trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) : WidgetBlockListViewModel { private var siteId: Int? = null private var colorMode: Color = Color.LIGHT @@ -83,7 +83,7 @@ class TodayWidgetBlockListViewModel statsUtils.toFormattedString(domainModel.views, MILLION), resourceProvider.getString(R.string.stats_visitors), statsUtils.toFormattedString(domainModel.visitors, MILLION), - targetTimeframe = if (trafficTabFeatureConfig.isEnabled()) { + targetTimeframe = if (trafficSubscribersTabFeatureConfig.isEnabled()) { StatsTimeframe.TRAFFIC } else StatsTimeframe.INSIGHTS ), @@ -94,9 +94,11 @@ class TodayWidgetBlockListViewModel statsUtils.toFormattedString(domainModel.likes, MILLION), resourceProvider.getString(R.string.stats_comments), statsUtils.toFormattedString(domainModel.comments, MILLION), - targetTimeframe = if (trafficTabFeatureConfig.isEnabled()) { + targetTimeframe = if (trafficSubscribersTabFeatureConfig.isEnabled()) { StatsTimeframe.TRAFFIC - } else StatsTimeframe.INSIGHTS + } else { + StatsTimeframe.INSIGHTS + } ) ) } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt index 348c33152b09..2094def7750b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetListProvider.kt @@ -13,7 +13,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject class TodayWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { @@ -24,7 +24,7 @@ class TodayWidgetListProvider(val context: Context, intent: Intent) : RemoteView lateinit var widgetUpdater: TodayWidgetUpdater @Inject - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private val colorMode: Color = intent.getColorMode() private val siteId: Int = intent.getIntExtra(SITE_ID_KEY, 0) @@ -72,7 +72,7 @@ class TodayWidgetListProvider(val context: Context, intent: Intent) : RemoteView val intent = Intent() intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.putExtra(WordPress.LOCAL_SITE_ID, uiModel.localSiteId) - if (trafficTabFeatureConfig.isEnabled()) { + if (trafficSubscribersTabFeatureConfig.isEnabled()) { intent.putExtra(StatsActivity.ARG_DESIRED_TIMEFRAME, StatsTimeframe.TRAFFIC) } else { intent.putExtra(StatsActivity.ARG_DESIRED_TIMEFRAME, StatsTimeframe.INSIGHTS) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetUpdater.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetUpdater.kt index 453f827eb925..7c8bb307b8b6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetUpdater.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetUpdater.kt @@ -19,7 +19,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.utils.WidgetUtils import org.wordpress.android.ui.stats.refresh.utils.trackWithWidgetType import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import javax.inject.Inject @@ -32,7 +32,7 @@ class TodayWidgetUpdater private val resourceProvider: ResourceProvider, private val widgetUtils: WidgetUtils, private val analyticsTrackerWrapper: AnalyticsTrackerWrapper, - private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) : WidgetUpdater { override fun updateAppWidget( context: Context, @@ -55,12 +55,12 @@ class TodayWidgetUpdater val widgetHasData = appPrefsWrapper.hasAppWidgetData(appWidgetId) if (networkAvailable && hasAccessToken && siteModel != null) { widgetUtils.setSiteIcon(siteModel, context, views, appWidgetId) - val timeframe = if (statsTrafficTabFeatureConfig.isEnabled()) { + val timeframe = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) { StatsTimeframe.TRAFFIC } else { StatsTimeframe.INSIGHTS } - val granularity = if (statsTrafficTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null + val granularity = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null siteModel.let { views.setOnClickPendingIntent( R.id.widget_title_container, diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt index e72726e3eb3b..cbdedb095be9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/views/ViewsWidgetListProvider.kt @@ -16,7 +16,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.IS_WIDE_VIEW_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject class ViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { @@ -27,7 +27,7 @@ class ViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteView lateinit var viewsWidgetUpdater: ViewsWidgetUpdater @Inject - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private val isWideView: Boolean = intent.getBooleanExtra(IS_WIDE_VIEW_KEY, true) private val colorMode = intent.getColorMode() @@ -91,7 +91,7 @@ class ViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteView rv.setViewVisibility(R.id.negative_change, View.GONE) } rv.setTextViewText(R.id.value, uiModel.value) - val granularity = if (trafficTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null + val granularity = if (trafficSubscribersTabFeatureConfig.isEnabled()) StatsGranularity.DAYS else null val intent = Intent() intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) intent.putExtra(INITIAL_SELECTED_PERIOD_KEY, uiModel.period) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt index 353a5f40c6e0..6869787720cf 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetListProvider.kt @@ -15,7 +15,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.SITE_ID_KEY import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.lists.widget.utils.getColorMode import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject class WeekViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory { @@ -26,7 +26,7 @@ class WeekViewsWidgetListProvider(val context: Context, intent: Intent) : Remote lateinit var widgetUpdater: WeekViewsWidgetUpdater @Inject - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private val colorMode: Color = intent.getColorMode() private val siteId: Int = intent.getIntExtra(SITE_ID_KEY, 0) @@ -73,8 +73,8 @@ class WeekViewsWidgetListProvider(val context: Context, intent: Intent) : Remote rv.setTextViewText(R.id.period, uiModel.key) rv.setTextViewText(R.id.value, uiModel.value) val intent = Intent() - val timeframe = if (trafficTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS - if (trafficTabFeatureConfig.isEnabled()) { + val timeframe = if (trafficSubscribersTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS + if (trafficSubscribersTabFeatureConfig.isEnabled()) { intent.putExtra(StatsActivity.ARG_GRANULARITY, StatsGranularity.WEEKS) } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetUpdater.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetUpdater.kt index 72c5326644c7..f72ac19a84d0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetUpdater.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/lists/widget/weeks/WeekViewsWidgetUpdater.kt @@ -20,7 +20,7 @@ import org.wordpress.android.ui.stats.refresh.lists.widget.utils.WidgetUtils import org.wordpress.android.ui.stats.refresh.utils.trackWithWidgetType import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import javax.inject.Inject @@ -32,7 +32,7 @@ class WeekViewsWidgetUpdater @Inject constructor( private val resourceProvider: ResourceProvider, private val widgetUtils: WidgetUtils, private val analyticsTrackerWrapper: AnalyticsTrackerWrapper, - private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) : WidgetUpdater { override fun updateAppWidget( context: Context, @@ -53,8 +53,8 @@ class WeekViewsWidgetUpdater @Inject constructor( views.setTextViewText(R.id.widget_title, resourceProvider.getString(R.string.stats_widget_weekly_views_name)) val hasAccessToken = accountStore.hasAccessToken() val widgetHasData = appPrefsWrapper.hasAppWidgetData(appWidgetId) - val timeframe = if (statsTrafficTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS - val granularity = if (statsTrafficTabFeatureConfig.isEnabled()) StatsGranularity.WEEKS else null + val timeframe = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) TRAFFIC else INSIGHTS + val granularity = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) StatsGranularity.WEEKS else null if (networkAvailable && hasAccessToken && siteModel != null) { widgetUtils.setSiteIcon(siteModel, context, views, appWidgetId) siteModel.let { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/DateSelectorViewUtils.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/DateSelectorViewUtils.kt index 2eb43ebea8f5..dc644cde146b 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/DateSelectorViewUtils.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/DateSelectorViewUtils.kt @@ -32,7 +32,7 @@ fun StatsListFragmentBinding.drawDateSelector(dateSelectorUiModel: DateSelectorU granularitySpinner.isVisible = dateSelectorUiModel?.isGranularitySpinnerVisible == true if (dateSelectorUiModel?.isGranularitySpinnerVisible != true) { - // StatsTrafficTabFeatureConfig is disabled. + // StatsTrafficSubscribersTabFeatureConfig is disabled. with(selectedDateTextView.layoutParams as ConstraintLayout.LayoutParams) { horizontalBias = 0f marginStart = selectedDateTextView.resources.getDimensionPixelSize(R.dimen.margin_small) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManager.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManager.kt index ef835102ca26..9387265286f6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManager.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManager.kt @@ -10,7 +10,7 @@ import org.wordpress.android.fluxc.network.utils.StatsGranularity.MONTHS import org.wordpress.android.fluxc.network.utils.StatsGranularity.WEEKS import org.wordpress.android.fluxc.network.utils.StatsGranularity.YEARS import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import javax.inject.Inject const val SELECTED_SECTION_KEY = "SELECTED_STATS_SECTION_KEY" @@ -18,7 +18,7 @@ const val SELECTED_SECTION_KEY = "SELECTED_STATS_SECTION_KEY" class SelectedSectionManager @Inject constructor( private val sharedPrefs: SharedPreferences, - private val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) { private val _liveSelectedSection = MutableLiveData() val liveSelectedSection: LiveData @@ -31,7 +31,11 @@ class SelectedSectionManager } fun getSelectedSection(): StatsSection { - val defaultValue = if (statsTrafficTabFeatureConfig.isEnabled()) StatsSection.TRAFFIC else StatsSection.INSIGHTS + val defaultValue = if (statsTrafficSubscribersTabFeatureConfig.isEnabled()) { + StatsSection.TRAFFIC + } else { + StatsSection.INSIGHTS + } val value = sharedPrefs.getString(SELECTED_SECTION_KEY, defaultValue.name) return value?.let { StatsSection.valueOf(value) } ?: StatsSection.INSIGHTS } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatter.kt b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatter.kt index 4ae0d0607848..0c6122bb6b8e 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatter.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatter.kt @@ -9,7 +9,7 @@ import org.wordpress.android.fluxc.network.utils.StatsGranularity.WEEKS import org.wordpress.android.fluxc.network.utils.StatsGranularity.YEARS import org.wordpress.android.fluxc.utils.SiteUtils import org.wordpress.android.util.LocaleManagerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import java.text.DateFormat import java.text.ParseException @@ -34,7 +34,7 @@ class StatsDateFormatter @Inject constructor( private val localeManagerWrapper: LocaleManagerWrapper, val resourceProvider: ResourceProvider, - val statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + val statsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig ) { private val inputFormat: SimpleDateFormat get() { @@ -115,7 +115,7 @@ class StatsDateFormatter val startCalendar = Calendar.getInstance() startCalendar.time = endCalendar.time startCalendar.add(Calendar.DAY_OF_WEEK, -6) - return printWeek(startCalendar, endCalendar, statsTrafficTabFeatureConfig.isEnabled()) + return printWeek(startCalendar, endCalendar, statsTrafficSubscribersTabFeatureConfig.isEnabled()) } MONTHS -> outputMonthFormat.format(date) .replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficSubscribersTabFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficSubscribersTabFeatureConfig.kt new file mode 100644 index 000000000000..ad1ed2c72b08 --- /dev/null +++ b/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficSubscribersTabFeatureConfig.kt @@ -0,0 +1,16 @@ +package org.wordpress.android.util.config + +import org.wordpress.android.BuildConfig +import org.wordpress.android.annotation.Feature +import javax.inject.Inject + +private const val STATS_TRAFFIC_SUBSCRIBERS_TAB_REMOTE_FIELD = "stats_traffic_subscribers_tab" + +@Feature(STATS_TRAFFIC_SUBSCRIBERS_TAB_REMOTE_FIELD, false) +class StatsTrafficSubscribersTabFeatureConfig @Inject constructor( + appConfig: AppConfig +) : FeatureConfig( + appConfig, + BuildConfig.STATS_TRAFFIC_SUBSCRIBERS_TAB, + STATS_TRAFFIC_SUBSCRIBERS_TAB_REMOTE_FIELD +) diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficTabFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficTabFeatureConfig.kt deleted file mode 100644 index 7b55f34878ed..000000000000 --- a/WordPress/src/main/java/org/wordpress/android/util/config/StatsTrafficTabFeatureConfig.kt +++ /dev/null @@ -1,16 +0,0 @@ -package org.wordpress.android.util.config - -import org.wordpress.android.BuildConfig -import org.wordpress.android.annotation.Feature -import javax.inject.Inject - -private const val STATS_TRAFFIC_TAB_REMOTE_FIELD = "stats_traffic_tab" - -@Feature(STATS_TRAFFIC_TAB_REMOTE_FIELD, false) -class StatsTrafficTabFeatureConfig @Inject constructor( - appConfig: AppConfig -) : FeatureConfig( - appConfig, - BuildConfig.STATS_TRAFFIC_TAB, - STATS_TRAFFIC_TAB_REMOTE_FIELD -) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt index 2cd57e936815..177cf4beb485 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/StatsViewModelTest.kt @@ -47,7 +47,7 @@ import org.wordpress.android.ui.utils.UiString.UiStringRes import org.wordpress.android.util.JetpackBrandingUtils import org.wordpress.android.util.NetworkUtilsWrapper import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.Event import org.wordpress.android.viewmodel.ResourceProvider @@ -99,7 +99,7 @@ class StatsViewModelTest : BaseUnitTest() { lateinit var jetpackFeatureRemovalOverlayUtil: JetpackFeatureRemovalOverlayUtil @Mock - lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private lateinit var viewModel: StatsViewModel private val _liveSelectedSection = MutableLiveData() private val liveSelectedSection: LiveData = _liveSelectedSection @@ -127,7 +127,7 @@ class StatsViewModelTest : BaseUnitTest() { notificationsTracker, jetpackBrandingUtils, jetpackFeatureRemovalOverlayUtil, - trafficTabFeatureConfig + trafficSubscribersTabFeatureConfig ) viewModel.start(1, StatsLaunchedFrom.QUICK_ACTIONS, TRAFFIC, null, false, null) diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapperTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapperTest.kt index 2e9df36f6232..06d21917996f 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapperTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/sections/insights/management/InsightsManagementMapperTest.kt @@ -25,12 +25,12 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.Header import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementViewModel.InsightListItem.InsightModel.Status -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig @ExperimentalCoroutinesApi class InsightsManagementMapperTest : BaseUnitTest() { @Mock - private lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private lateinit var insightsManagementMapper: InsightsManagementMapper private var insightTypeCount = 13 // POSTS_AND_PAGES_INSIGHTS.size + ACTIVITY_INSIGHTS.size + GENERAL_INSIGHTS.size @@ -40,7 +40,7 @@ class InsightsManagementMapperTest : BaseUnitTest() { fun setUp() { insightsManagementMapper = InsightsManagementMapper( testDispatcher(), - trafficTabFeatureConfig + trafficSubscribersTabFeatureConfig ) } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModelTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModelTest.kt index e695705448b7..e665277cf1e9 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModelTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/lists/widget/today/TodayWidgetBlockListViewModelTest.kt @@ -21,7 +21,7 @@ import org.wordpress.android.ui.prefs.AppPrefsWrapper import org.wordpress.android.ui.stats.refresh.lists.widget.WidgetBlockListProvider.BlockItemUiModel import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color import org.wordpress.android.ui.stats.refresh.utils.StatsUtils -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider @RunWith(MockitoJUnitRunner::class) @@ -51,7 +51,7 @@ class TodayWidgetBlockListViewModelTest { private lateinit var todayWidgetUpdater: TodayWidgetUpdater @Mock - private lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig private lateinit var viewModel: TodayWidgetBlockListViewModel private val siteId: Int = 15 private val appWidgetId: Int = 1 @@ -66,7 +66,7 @@ class TodayWidgetBlockListViewModelTest { todayWidgetUpdater, appPrefsWrapper, statsUtils, - trafficTabFeatureConfig + trafficSubscribersTabFeatureConfig ) viewModel.start(siteId, color, appWidgetId) whenever(statsUtils.toFormattedString(any(), any())).then { (it.arguments[0] as Int).toString() } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManagerTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManagerTest.kt index 5de19d62b157..164b263a442b 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManagerTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/SelectedSectionManagerTest.kt @@ -13,12 +13,12 @@ import org.mockito.kotlin.whenever import org.wordpress.android.BaseUnitTest import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.MONTHS -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig @ExperimentalCoroutinesApi class SelectedSectionManagerTest : BaseUnitTest() { @Mock - private lateinit var trafficTabFeatureConfig: StatsTrafficTabFeatureConfig + private lateinit var trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig @Mock lateinit var sharedPreferences: SharedPreferences @@ -29,7 +29,7 @@ class SelectedSectionManagerTest : BaseUnitTest() { @Before fun setUp() { - selectedSectionManager = SelectedSectionManager(sharedPreferences, trafficTabFeatureConfig) + selectedSectionManager = SelectedSectionManager(sharedPreferences, trafficSubscribersTabFeatureConfig) whenever(sharedPreferences.edit()).thenReturn(sharedPreferencesEditor) } diff --git a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatterTest.kt b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatterTest.kt index 000d42ebf933..bec7874c5f06 100644 --- a/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatterTest.kt +++ b/WordPress/src/test/java/org/wordpress/android/ui/stats/refresh/utils/StatsDateFormatterTest.kt @@ -17,7 +17,7 @@ import org.wordpress.android.fluxc.network.utils.StatsGranularity.MONTHS import org.wordpress.android.fluxc.network.utils.StatsGranularity.WEEKS import org.wordpress.android.fluxc.network.utils.StatsGranularity.YEARS import org.wordpress.android.util.LocaleManagerWrapper -import org.wordpress.android.util.config.StatsTrafficTabFeatureConfig +import org.wordpress.android.util.config.StatsTrafficSubscribersTabFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import java.util.Calendar import java.util.Locale @@ -29,7 +29,7 @@ class StatsDateFormatterTest : BaseUnitTest() { lateinit var localeManagerWrapper: LocaleManagerWrapper @Mock - lateinit var statsTrafficTabFeatureConfig: StatsTrafficTabFeatureConfig + lateinit var mStatsTrafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig @Mock lateinit var resourceProvider: ResourceProvider @@ -38,8 +38,12 @@ class StatsDateFormatterTest : BaseUnitTest() { @Before fun setUp() { whenever(localeManagerWrapper.getLocale()).thenReturn(Locale.US) - whenever(statsTrafficTabFeatureConfig.isEnabled()).thenReturn(false) - statsDateFormatter = StatsDateFormatter(localeManagerWrapper, resourceProvider, statsTrafficTabFeatureConfig) + whenever(mStatsTrafficSubscribersTabFeatureConfig.isEnabled()).thenReturn(false) + statsDateFormatter = StatsDateFormatter( + localeManagerWrapper, + resourceProvider, + mStatsTrafficSubscribersTabFeatureConfig + ) } @Test @@ -79,7 +83,7 @@ class StatsDateFormatterTest : BaseUnitTest() { @Test fun `prints a week date in the same year in string format with stats traffic tab enabled`() { - whenever(statsTrafficTabFeatureConfig.isEnabled()).thenReturn(true) + whenever(mStatsTrafficSubscribersTabFeatureConfig.isEnabled()).thenReturn(true) val unparsedDate = "2018W12W19" val result = "Dec 17 - Dec 23, 2018" whenever( @@ -97,7 +101,7 @@ class StatsDateFormatterTest : BaseUnitTest() { @Test fun `prints a week date in two different years in string format with traffic tab enabled`() { - whenever(statsTrafficTabFeatureConfig.isEnabled()).thenReturn(true) + whenever(mStatsTrafficSubscribersTabFeatureConfig.isEnabled()).thenReturn(true) val unparsedDate = "2018W12W31" val result = "Dec 31, 2018 - Jan 6, 2019" whenever(