Skip to content

Commit

Permalink
Move StatsLaunchedFrom to a more appropriate place
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Feb 20, 2024
1 parent 0668134 commit 88960d9
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@
import org.wordpress.android.ui.stats.StatsTimeframe;
import org.wordpress.android.ui.stats.StatsViewType;
import org.wordpress.android.ui.stats.refresh.StatsActivity;
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom;
import org.wordpress.android.ui.stats.refresh.StatsViewAllActivity;
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection;
import org.wordpress.android.ui.stats.refresh.lists.detail.StatsDetailActivity;
import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDateProvider.SelectedDate;
import org.wordpress.android.ui.stats.refresh.lists.sections.insights.management.InsightsManagementActivity;
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom;
import org.wordpress.android.ui.stockmedia.StockMediaPickerActivity;
import org.wordpress.android.ui.stories.StoryComposerActivity;
import org.wordpress.android.ui.suggestion.SuggestionActivity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.wordpress.android.fluxc.store.SiteStore;
import org.wordpress.android.login.LoginMode;
import org.wordpress.android.ui.accounts.LoginActivity;
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom;
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.ToastUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.wordpress.android.analytics.AnalyticsTracker;
import org.wordpress.android.fluxc.model.SiteModel;
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper;
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom;
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom;
import org.wordpress.android.util.AppLog;

import javax.inject.Inject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import org.wordpress.android.ui.deeplinks.DeepLinkNavigator.NavigateAction.ViewP
import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource.DEEP_LINK
import org.wordpress.android.ui.sitemonitor.SiteMonitorType
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.util.UriWrapper
import javax.inject.Inject

Expand Down Expand Up @@ -66,14 +66,14 @@ class DeepLinkNavigator
is OpenStatsForSite -> ActivityLauncher.viewStatsInNewStack(
activity,
navigateAction.site,
StatsActivity.StatsLaunchedFrom.LINK
StatsLaunchedFrom.LINK
)

is OpenStatsForSiteAndTimeframe -> ActivityLauncher.viewStatsInNewStack(
activity,
navigateAction.site,
navigateAction.statsTimeframe,
StatsActivity.StatsLaunchedFrom.LINK
StatsLaunchedFrom.LINK
)

OpenReader -> ActivityLauncher.viewReaderInNewStack(activity)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
import org.wordpress.android.ui.review.ReviewViewModel;
import org.wordpress.android.ui.sitecreation.misc.SiteCreationSource;
import org.wordpress.android.ui.stats.StatsTimeframe;
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom;
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom;
import org.wordpress.android.ui.stories.intro.StoriesIntroDialogFragment;
import org.wordpress.android.ui.uploads.UploadActionUseCase;
import org.wordpress.android.ui.uploads.UploadUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ import org.wordpress.android.ui.quickstart.QuickStartTracker
import org.wordpress.android.ui.reader.ReaderActivityLauncher
import org.wordpress.android.ui.reader.tracker.ReaderTracker
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.uploads.UploadService
import org.wordpress.android.ui.uploads.UploadUtilsWrapper
import org.wordpress.android.ui.utils.TitleSubtitleSnackbarSpannable
Expand Down Expand Up @@ -611,7 +611,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment),
is SiteNavigationAction.OpenStats -> ActivityLauncher.viewBlogStats(
activity,
action.site,
StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS
StatsLaunchedFrom.QUICK_ACTIONS
)

is SiteNavigationAction.ConnectJetpackForStats ->
Expand Down Expand Up @@ -678,7 +678,7 @@ class MySiteFragment : Fragment(R.layout.my_site_fragment),
requireActivity(),
action.site,
StatsTimeframe.INSIGHTS,
StatsActivity.StatsLaunchedFrom.TODAY_STATS_CARD
StatsLaunchedFrom.TODAY_STATS_CARD
)

is SiteNavigationAction.OpenExternalUrl ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import org.wordpress.android.ui.mysite.items.listitem.ListItemAction
import org.wordpress.android.ui.pages.SnackbarMessageHolder
import org.wordpress.android.ui.prefs.SiteSettingsFragment
import org.wordpress.android.ui.quickstart.QuickStartMySitePrompts
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.utils.ListItemInteraction
import org.wordpress.android.ui.utils.UiString
import org.wordpress.android.util.LocaleManager
Expand Down Expand Up @@ -147,7 +147,7 @@ class MenuActivity : AppCompatActivity() {
is SiteNavigationAction.OpenStats -> ActivityLauncher.viewBlogStats(
this,
action.site,
StatsActivity.StatsLaunchedFrom.ROW
StatsLaunchedFrom.ROW
)

is SiteNavigationAction.OpenDomains -> ActivityLauncher.viewDomainsDashboardActivity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import org.wordpress.android.ui.reader.comments.ThreadedCommentsActionSource;
import org.wordpress.android.ui.reader.tracker.ReaderTracker;
import org.wordpress.android.ui.stats.StatsViewType;
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom;
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom;
import org.wordpress.android.util.AppLog;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.ToastUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.wordpress.android.ui.reader.comments.ThreadedCommentsActionSource.ACT
import org.wordpress.android.ui.reader.tracker.ReaderTracker
import org.wordpress.android.ui.reader.utils.ReaderUtils
import org.wordpress.android.ui.stats.StatsViewType.FOLLOWERS
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.util.AppLog
import org.wordpress.android.util.AppLog.T.API
import org.wordpress.android.util.ToastUtils
Expand Down Expand Up @@ -118,7 +118,7 @@ class FormattableContentClickHandler @Inject constructor(
if (rangeType == FormattableRangeType.FOLLOW) {
ActivityLauncher.viewAllTabbedInsightsStats(activity, FOLLOWERS, 0, site.id)
} else {
ActivityLauncher.viewBlogStats(activity, site, StatsActivity.StatsLaunchedFrom.ACTIVITY_LOG)
ActivityLauncher.viewBlogStats(activity, site, StatsLaunchedFrom.ACTIVITY_LOG)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import org.wordpress.android.ui.ActivityLauncher
import org.wordpress.android.ui.LocaleAwareActivity
import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.util.JetpackBrandingUtils
import javax.inject.Inject
Expand Down Expand Up @@ -90,17 +91,4 @@ class StatsActivity : LocaleAwareActivity() {
notificationType?.let { putExtra(ARG_NOTIFICATION_TYPE, it) }
}
}

enum class StatsLaunchedFrom(val value: String) {
QUICK_ACTIONS("quick_actions"),
TODAY_STATS_CARD("today_stats_card"),
ROW("row"),
POSTS("posts"),
WIDGET("widget"),
NOTIFICATION("notification"),
LINK("link"),
SHORTCUT("shortcut"),
ACTIVITY_LOG("activity_log"),
JETPACK_CONNECTION("jetpack_connection")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import org.wordpress.android.ui.stats.StatsTimeframe.DAY
import org.wordpress.android.ui.stats.StatsTimeframe.MONTH
import org.wordpress.android.ui.stats.StatsTimeframe.WEEK
import org.wordpress.android.ui.stats.StatsTimeframe.YEAR
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Failure.NetworkUnavailable
import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Failure.RemoteRequestFailure
import org.wordpress.android.ui.stats.refresh.StatsModuleActivateRequestState.Success
Expand All @@ -47,6 +46,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDa
import org.wordpress.android.ui.stats.refresh.utils.NewsCardHandler
import org.wordpress.android.ui.stats.refresh.utils.SelectedSectionManager
import org.wordpress.android.ui.stats.refresh.utils.SelectedTrafficGranularityManager
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.ui.stats.refresh.utils.toStatsGranularity
import org.wordpress.android.ui.stats.refresh.utils.trackStatsAccessed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalOverlayUtil
import org.wordpress.android.ui.jetpackoverlay.JetpackOverlayConnectedFeature
import org.wordpress.android.ui.pages.SnackbarMessageHolder
import org.wordpress.android.ui.stats.refresh.BLOCK_DETAIL_USE_CASE
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.lists.BaseListUseCase
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.utils.StatsPostProvider
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.ui.stats.refresh.utils.trackStatsAccessed
Expand Down Expand Up @@ -55,7 +55,7 @@ class StatsDetailViewModel
) {
analyticsTrackerWrapper.trackStatsAccessed(
statsSiteProvider.siteModel,
StatsActivity.StatsLaunchedFrom.POSTS.value
StatsLaunchedFrom.POSTS.value
)

statsPostProvider.init(postId, postType, postTitle, postUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import org.wordpress.android.WordPress
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.StatsTimeframe.INSIGHTS
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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

class WidgetBlockListProvider(val context: Context, val viewModel: WidgetBlockListViewModel, intent: Intent) :
RemoteViewsFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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 javax.inject.Inject

class AllTimeWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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 javax.inject.Inject

class TodayWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import org.wordpress.android.fluxc.model.stats.time.VisitsAndViewsModel.PeriodDa
import org.wordpress.android.modules.UI_THREAD
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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.WidgetService
import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color
import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color.DARK
import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsColorSelectionViewModel.Color.LIGHT
import org.wordpress.android.ui.stats.refresh.lists.widget.configuration.StatsWidgetConfigureFragment.WidgetType
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.util.image.ImageManager
import org.wordpress.android.util.image.ImageType.ICON
import org.wordpress.android.viewmodel.ResourceProvider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import org.wordpress.android.WordPress
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.Companion.INITIAL_SELECTED_PERIOD_KEY
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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 javax.inject.Inject

class ViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import org.wordpress.android.R
import org.wordpress.android.WordPress
import org.wordpress.android.ui.stats.StatsTimeframe
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.StatsActivity.StatsLaunchedFrom
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 javax.inject.Inject

class WeekViewsWidgetListProvider(val context: Context, intent: Intent) : RemoteViewsFactory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ private const val MINIFIED_WIDGET_PROPERTY = "minified"
private const val CHIP_VIEWS_PROPERTY = "views"
private const val CHIP_VISITORS__PROPERTY = "visitors"

enum class StatsLaunchedFrom(val value: String) {
QUICK_ACTIONS("quick_actions"),
TODAY_STATS_CARD("today_stats_card"),
ROW("row"),
POSTS("posts"),
WIDGET("widget"),
NOTIFICATION("notification"),
LINK("link"),
SHORTCUT("shortcut"),
ACTIVITY_LOG("activity_log"),
JETPACK_CONNECTION("jetpack_connection")
}

fun AnalyticsTrackerWrapper.trackStatsAccessed(site: SiteModel, tapSource: String) =
track(stat = Stat.STATS_ACCESSED, site = site, properties = mutableMapOf(TAP_SOURCE_PROPERTY to tapSource))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.wordpress.android.ui.jetpackoverlay.JetpackFeatureRemovalPhaseHelper
import org.wordpress.android.ui.notifications.SystemNotificationsTracker
import org.wordpress.android.ui.prefs.AppPrefsWrapper
import org.wordpress.android.ui.stats.StatsTimeframe.WEEK
import org.wordpress.android.ui.stats.refresh.StatsActivity
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.utils.StatsUtils
import org.wordpress.android.util.SiteUtilsWrapper
import org.wordpress.android.viewmodel.ContextProvider
Expand Down Expand Up @@ -76,7 +76,7 @@ class WeeklyRoundupNotifier @Inject constructor(
WEEK,
data.period,
WEEKLY_ROUNDUP,
StatsActivity.StatsLaunchedFrom.NOTIFICATION,
StatsLaunchedFrom.NOTIFICATION,
notificationId,
FLAG_CANCEL_CURRENT or FLAG_IMMUTABLE
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.granular.SelectedDa
import org.wordpress.android.ui.stats.refresh.utils.NewsCardHandler
import org.wordpress.android.ui.stats.refresh.utils.SelectedSectionManager
import org.wordpress.android.ui.stats.refresh.utils.SelectedTrafficGranularityManager
import org.wordpress.android.ui.stats.refresh.utils.StatsLaunchedFrom
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.ui.stats.refresh.utils.trackWithGranularity
import org.wordpress.android.ui.utils.UiString.UiStringRes
Expand Down Expand Up @@ -129,7 +130,7 @@ class StatsViewModelTest : BaseUnitTest() {
trafficTabFeatureConfig
)

viewModel.start(1, StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS, TRAFFIC, null, false, null)
viewModel.start(1, StatsLaunchedFrom.QUICK_ACTIONS, TRAFFIC, null, false, null)
}

@Test
Expand Down Expand Up @@ -352,7 +353,7 @@ class StatsViewModelTest : BaseUnitTest() {

private fun startViewModel(statsModuleEnabled: Boolean = true) {
whenever(site.isActiveModuleEnabled(any())).thenReturn(statsModuleEnabled)
viewModel.start(1, StatsActivity.StatsLaunchedFrom.QUICK_ACTIONS, null, null, false, null)
viewModel.start(1, StatsLaunchedFrom.QUICK_ACTIONS, null, null, false, null)
}

private val networkUnavailableError = StatsModuleActivateRequestState.Failure.NetworkUnavailable
Expand Down

0 comments on commit 88960d9

Please sign in to comment.