Skip to content

Commit

Permalink
Merge pull request #20661 from wordpress-mobile/rename-stats-traffic-…
Browse files Browse the repository at this point in the history
…tab-feature-config

Rename `stats_traffic_tab` config to `stats_traffic_subscribers_tab`
  • Loading branch information
aditi-bhatia authored Apr 18, 2024
2 parents 921ce21 + af9901f commit f761209
Show file tree
Hide file tree
Showing 26 changed files with 114 additions and 100 deletions.
2 changes: 1 addition & 1 deletion WordPress/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"stats_traffic_tab": true
"stats_traffic_subscribers_tab": true
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -129,7 +129,7 @@ class StatsModule {
actionCardGrowUseCase: ActionCardGrowUseCase,
actionCardReminderUseCase: ActionCardReminderUseCase,
actionCardScheduleUseCase: ActionCardScheduleUseCase,
trafficTabFeatureConfig: StatsTrafficTabFeatureConfig
trafficSubscribersTabFeatureConfig: StatsTrafficSubscribersTabFeatureConfig
): List<@JvmSuppressWildcards BaseStatsUseCase<*, *>> {
val useCases = mutableListOf<BaseStatsUseCase<*, *>>()
if (BuildConfig.IS_JETPACK_APP) {
Expand All @@ -144,7 +144,7 @@ class StatsModule {
useCases.add(followerTotalsUseCase)
}

if (!trafficTabFeatureConfig.isEnabled()) {
if (!trafficSubscribersTabFeatureConfig.isEnabled()) {
useCases.add(todayStatsUseCase)
}

Expand Down Expand Up @@ -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<StatsSection, BaseListUseCase> {
return if (trafficTabFeatureConfig.isEnabled()) {
return if (trafficSubscribersTabFeatureConfig.isEnabled()) {
mapOf(
StatsSection.TRAFFIC to trafficUseCase,
StatsSection.INSIGHTS to insightsUseCase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -288,7 +288,7 @@ class StatsViewAllFragment : Fragment(R.layout.stats_view_all_fragment) {
private fun loadData(recyclerView: RecyclerView, data: List<BlockListItem>) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<Boolean>()
val isRefreshing: LiveData<Boolean> = _isRefreshing
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
}
Expand All @@ -209,7 +209,7 @@ class StatsViewModel
selectedTrafficGranularityManager.setSelectedTrafficGranularity(it)
}
}
updateSelectedSectionByTrafficTabFeatureConfig()
updateSelectedSectionByTrafficSubscribersTabFeatureConfig()
trackSectionSelected(statsSectionManager.getSelectedSection())

val initialGranularity = granularity ?: initialSection?.toStatsGranularity()
Expand Down Expand Up @@ -252,16 +252,16 @@ 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 ||
selectedSection == StatsSection.MONTHS ||
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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -332,7 +332,7 @@ class StatsListFragment : ViewPagerFragment(R.layout.stats_list_fragment) {
private fun StatsListFragmentBinding.updateInsights(statsState: List<StatsBlock>) {
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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<InsightType>, onClick: (InsightType) -> Unit) =
withContext(bgDispatcher) {
val insightListItems = mutableListOf<InsightListItem>()
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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
),
Expand All @@ -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
}
)
)
}
Expand Down
Loading

0 comments on commit f761209

Please sign in to comment.