diff --git a/WordPress/build.gradle b/WordPress/build.gradle index 50b55228eb91..1660b4a665e9 100644 --- a/WordPress/build.gradle +++ b/WordPress/build.gradle @@ -76,6 +76,7 @@ android { buildConfigField "boolean", "WP_STORIES_AVAILABLE", "true" buildConfigField "boolean", "ANY_FILE_UPLOAD", "true" buildConfigField "boolean", "CONSOLIDATED_MEDIA_PICKER", "false" + buildConfigField "boolean", "ACTIVITY_LOG_FILTERS", "false" buildConfigField "boolean", "ENABLE_FEATURE_CONFIGURATION", "true" } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt index db1e8d4d3c15..8fc265918afe 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt +++ b/WordPress/src/main/java/org/wordpress/android/ui/activitylog/list/ActivityLogListFragment.kt @@ -18,6 +18,7 @@ import org.wordpress.android.WordPress import org.wordpress.android.fluxc.model.SiteModel import org.wordpress.android.ui.ActivityLauncher import org.wordpress.android.ui.posts.BasicFragmentDialog +import org.wordpress.android.ui.utils.UiHelpers import org.wordpress.android.util.NetworkUtils import org.wordpress.android.util.WPSwipeToRefreshHelper.buildSwipeToRefreshHelper import org.wordpress.android.util.helpers.SwipeToRefreshHelper @@ -29,6 +30,7 @@ import javax.inject.Inject class ActivityLogListFragment : Fragment() { @Inject lateinit var viewModelFactory: ViewModelProvider.Factory + @Inject lateinit var uiHelpers: UiHelpers private lateinit var viewModel: ActivityLogViewModel private lateinit var swipeToRefreshHelper: SwipeToRefreshHelper @@ -94,6 +96,10 @@ class ActivityLogListFragment : Fragment() { refreshProgressBars(listStatus) }) + viewModel.dateRangePickerVisibility.observe(viewLifecycleOwner, Observer { visibility -> + uiHelpers.updateVisibility(date_range_picker, visibility) + }) + viewModel.showItemDetail.observe(viewLifecycleOwner, Observer { if (it is ActivityLogListItem.Event) { ActivityLauncher.viewActivityLogDetailForResult(activity, viewModel.site, it.activityId) diff --git a/WordPress/src/main/java/org/wordpress/android/util/config/ActivityLogFiltersFeatureConfig.kt b/WordPress/src/main/java/org/wordpress/android/util/config/ActivityLogFiltersFeatureConfig.kt new file mode 100644 index 000000000000..33bd8fe19a9d --- /dev/null +++ b/WordPress/src/main/java/org/wordpress/android/util/config/ActivityLogFiltersFeatureConfig.kt @@ -0,0 +1,15 @@ +package org.wordpress.android.util.config + +import org.wordpress.android.BuildConfig +import org.wordpress.android.annotation.FeatureInDevelopment +import javax.inject.Inject + +/** + * Configuration of the Activity Log Filters feature. + */ +@FeatureInDevelopment +class ActivityLogFiltersFeatureConfig +@Inject constructor(appConfig: AppConfig) : FeatureConfig( + appConfig, + BuildConfig.ACTIVITY_LOG_FILTERS +) diff --git a/WordPress/src/main/java/org/wordpress/android/viewmodel/activitylog/ActivityLogViewModel.kt b/WordPress/src/main/java/org/wordpress/android/viewmodel/activitylog/ActivityLogViewModel.kt index 0a0293451109..d140ef1a7ee7 100644 --- a/WordPress/src/main/java/org/wordpress/android/viewmodel/activitylog/ActivityLogViewModel.kt +++ b/WordPress/src/main/java/org/wordpress/android/viewmodel/activitylog/ActivityLogViewModel.kt @@ -21,6 +21,7 @@ import org.wordpress.android.ui.activitylog.list.ActivityLogListItem.Footer import org.wordpress.android.ui.activitylog.list.ActivityLogListItem.Header import org.wordpress.android.ui.activitylog.list.ActivityLogListItem.Loading import org.wordpress.android.util.AppLog +import org.wordpress.android.util.config.ActivityLogFiltersFeatureConfig import org.wordpress.android.viewmodel.ResourceProvider import org.wordpress.android.viewmodel.ScopedViewModel import org.wordpress.android.viewmodel.SingleLiveEvent @@ -33,6 +34,7 @@ class ActivityLogViewModel @Inject constructor( private val activityLogStore: ActivityLogStore, private val rewindStatusService: RewindStatusService, private val resourceProvider: ResourceProvider, + private val activityLogFiltersFeatureConfig: ActivityLogFiltersFeatureConfig, @param:Named(UI_THREAD) private val uiDispatcher: CoroutineDispatcher ) : ScopedViewModel(uiDispatcher) { enum class ActivityLogListStatus { @@ -53,6 +55,10 @@ class ActivityLogViewModel @Inject constructor( val eventListStatus: LiveData get() = _eventListStatus + private val _dateRangePickerVisibility = MutableLiveData() + val dateRangePickerVisibility: LiveData + get() = _dateRangePickerVisibility + private val _showRewindDialog = SingleLiveEvent() val showRewindDialog: LiveData get() = _showRewindDialog @@ -116,6 +122,8 @@ class ActivityLogViewModel @Inject constructor( reloadEvents(done = true) requestEventsUpdate(false) + _dateRangePickerVisibility.value = activityLogFiltersFeatureConfig.isEnabled() + isStarted = true } diff --git a/WordPress/src/main/res/layout/activity_log_list_fragment.xml b/WordPress/src/main/res/layout/activity_log_list_fragment.xml index 0d70dc379e1c..20d0a7a07bd9 100644 --- a/WordPress/src/main/res/layout/activity_log_list_fragment.xml +++ b/WordPress/src/main/res/layout/activity_log_list_fragment.xml @@ -5,10 +5,19 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + + android:layout_height="match_parent" + android:layout_below="@id/date_range_picker"> private var events: MutableList?> = mutableListOf() @@ -96,7 +98,13 @@ class ActivityLogViewModelTest { @Before fun setUp() = runBlocking { - viewModel = ActivityLogViewModel(store, rewindStatusService, resourceProvider, Dispatchers.Unconfined) + viewModel = ActivityLogViewModel( + store, + rewindStatusService, + resourceProvider, + activityLogFiltersFeatureConfig, + Dispatchers.Unconfined + ) viewModel.site = site viewModel.events.observeForever { events.add(it) } viewModel.eventListStatus.observeForever { eventListStatuses.add(it) } @@ -318,6 +326,24 @@ class ActivityLogViewModelTest { assertFetchEvents(true) } + @Test + fun dateRangePickerIsNotVisibleWhenFiltersFeatureFlagIsDisabled() = runBlocking { + whenever(activityLogFiltersFeatureConfig.isEnabled()).thenReturn(false) + + viewModel.start(site) + + assertEquals(false, viewModel.dateRangePickerVisibility.value) + } + + @Test + fun dateRangePickerIsVisibleWhenFiltersFeatureFlagIsEnabled() = runBlocking { + whenever(activityLogFiltersFeatureConfig.isEnabled()).thenReturn(true) + + viewModel.start(site) + + assertEquals(true, viewModel.dateRangePickerVisibility.value) + } + private suspend fun assertFetchEvents(canLoadMore: Boolean = false) { verify(store).fetchActivities(fetchActivityLogCaptor.capture())