Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
3f6e429
Add insights management list item resources
0nko Mar 25, 2019
ba8fcc9
Update the insights management fragment layout with text items
0nko Mar 25, 2019
aaa5567
Add the insights management list adapter and view holder
0nko Mar 25, 2019
cc5c80a
Add InsightModel and implement the removed insights loading
0nko Mar 25, 2019
fae598f
Add the drawable resources for insights management
0nko Mar 26, 2019
32136a4
Add new drag & drop hint string resource
0nko Mar 26, 2019
b54109f
Update the list item layout
0nko Mar 26, 2019
b4f3b2e
Add the added insights list and drag & drop hint
0nko Mar 26, 2019
20665e3
Add drag & drop ordering to added insights
0nko Mar 27, 2019
ed85544
Remove redundant code
0nko Mar 27, 2019
92d2c0b
Add the save button to the insights management screen
0nko Mar 27, 2019
46fae9b
Fix snackbar display
0nko Mar 27, 2019
ed38594
Update the ViewModel after dragging items
0nko Mar 27, 2019
a6a2b8a
Whitespace clean up
0nko Mar 27, 2019
2671904
Fix insights diff util comparisons
0nko Mar 27, 2019
9fae18a
Add insights adding and removal functionality
0nko Mar 27, 2019
36b8aa2
Update string resources
0nko Mar 28, 2019
00bed85
Create separate for added and removed insight types
0nko Mar 28, 2019
2634449
Animate list resize changes
0nko Mar 28, 2019
47d7c1a
Merge branch 'feature/manage_insights_readonly' into issue/9464-manag…
0nko Mar 28, 2019
9e33dc9
Close the insights management instead of showing a snackbar message
0nko Mar 28, 2019
39a2f9d
Update the FluxC reference
0nko Apr 1, 2019
f9830d8
Rename the layout view IDs for consistency
0nko Apr 1, 2019
d53c388
Initialize empty and error views
0nko Apr 1, 2019
08b47ad
Remove unused string resource
0nko Apr 1, 2019
fa838f8
Add list item decorators
0nko Apr 1, 2019
08973d1
Don't wait for data to refresh when leaving the insights management
0nko Apr 1, 2019
24f5351
Fix the empty isnights actionable screen display
0nko Apr 1, 2019
8e6998b
Fix ktlint
0nko Apr 1, 2019
73be580
Update the release notes
0nko Apr 1, 2019
bb5f8c1
Only load insights once
0nko Apr 9, 2019
2415e7c
Use larger vertical margin for the subtitle
0nko Apr 9, 2019
422918d
Hide the Save button until some change is made
0nko Apr 9, 2019
3789129
Show the touch feedback on ellipsis tap
0nko Apr 9, 2019
b4c2941
Force showing a menu icon
0nko Apr 10, 2019
8081564
Replace the simple popup menu with a custom popup window
0nko Apr 10, 2019
151714a
Fix the resources
0nko Apr 10, 2019
d1f2915
Change the menu width
0nko Apr 10, 2019
7b8fa04
Allow dragged list items to move over the entire screen
0nko Apr 11, 2019
8cba908
Make the added list items topmost
0nko Apr 11, 2019
8ceb2b8
Display a shadow (elevation) while an item is being dragged
0nko Apr 11, 2019
3c4ce39
Add the Edit button to the bottom of the insights list
0nko Apr 12, 2019
d5f313a
Remove the old Manage menu
0nko Apr 12, 2019
01420e1
Add a new type of StatsBlock to allow empty background for the link b…
0nko Apr 12, 2019
0b234fe
Disable the click listener after a tap to prevent a crash
0nko Apr 12, 2019
5fc462d
Avoid using LiveData state as in-memory cache
0nko Apr 12, 2019
c6145a1
Use constraint layout to fix the peroper list height that shows all i…
0nko Apr 12, 2019
942dbfc
Optimize imports
0nko Apr 12, 2019
c2412c8
Prevent long-press dragging
0nko Apr 12, 2019
9ec6c79
Set basline aligned attribute for better performance
0nko Apr 12, 2019
d6c613e
Remove unused string resource
0nko Apr 12, 2019
2c9fd4e
Optimize imports
0nko Apr 12, 2019
f03cd7f
Get rid of an extra coroutine builder
0nko Apr 12, 2019
a037332
Remove unused string resource
0nko Apr 12, 2019
8f35da2
Merge branch 'feature/manage_insights_readonly' into issue/9464-manag…
0nko Apr 12, 2019
8452113
Add the missing drawable resources
0nko Apr 12, 2019
deecbba
Remove the common statsTypes parameter from StatsBlocks
0nko Apr 15, 2019
88b0acf
Move the UiModel construction to the mapper
0nko Apr 15, 2019
b4f3bbc
Fix the unit tests
0nko Apr 15, 2019
1af8339
Fix ktlint
0nko Apr 15, 2019
8645831
Fix the newly added insights data loading
0nko Apr 17, 2019
ddbf15a
Add additional padding between the footer and the Add Insights header
0nko Apr 17, 2019
02bf4e7
Add the reduced width layout for wide screens (landcape)
0nko Apr 17, 2019
35bbc91
Add a custom divider that has a padding at the beginning
0nko Apr 17, 2019
b0b080f
Use a regular button style
0nko Apr 17, 2019
574ded8
Delay animations until the insights are loaded to prevent weird slide…
0nko Apr 17, 2019
bbbdccc
Update the layout paddings
0nko Apr 17, 2019
afd2221
Merge branch 'feature/manage_insights_readonly' into issue/9464-manag…
0nko Apr 18, 2019
11a9497
Update the FluxC reference and make the necessary code changes
0nko Apr 18, 2019
a5c3ac9
Fix the doble blocks bug
0nko Apr 18, 2019
e1ab010
Always show the Edit button
0nko Apr 18, 2019
f30ac7f
Correct the layout paddings
0nko Apr 23, 2019
7874a42
Fix the failing unit test
0nko Apr 23, 2019
4640b84
Add the context menu to the Annual stats block
0nko Apr 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* Updated color scheme to Classic Bright
* Adds support for .blog subdomains for the new site creation flow

* New Insights Management for selecting the most relevant stats

12.1
-----
* Design improvements for the new site creation flow
Expand Down
2 changes: 1 addition & 1 deletion WordPress/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@
android:theme="@style/Calypso.NoActionBar" />
<activity
android:name=".ui.stats.refresh.lists.sections.insights.management.InsightsManagementActivity"
android:label="@string/manage_insights"
android:label="@string/stats_manage_insights"
android:launchMode="singleTop"
android:theme="@style/CalypsoTheme" />
<activity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.HEADER
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.INFO
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LINK
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LINK_BUTTON
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LIST_ITEM
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LIST_ITEM_WITH_ICON
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem.Type.LOADING_ITEM
Expand Down Expand Up @@ -65,6 +66,7 @@ class BlockDiffCallback(
CHART_LEGEND,
REFERRED_ITEM,
QUICK_SCAN_ITEM,
LINK_BUTTON,
EMPTY -> oldItem == newItem
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import android.support.v4.app.FragmentManager
import android.support.v4.app.FragmentPagerAdapter
import android.support.v4.view.ViewCompat
import android.view.LayoutInflater
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
Expand Down Expand Up @@ -55,35 +52,13 @@ class StatsFragment : DaggerFragment() {
private lateinit var swipeToRefreshHelper: SwipeToRefreshHelper
@Inject lateinit var navigator: StatsNavigator

private var menu: Menu? = null

private var restorePreviousSearch = false

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setHasOptionsMenu(true)
}

override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
setHasOptionsMenu(true)

return inflater.inflate(R.layout.stats_fragment, container, false)
}

override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
super.onCreateOptionsMenu(menu, inflater)

inflater?.inflate(R.menu.menu_stats_insights, menu)
this.menu = menu
}

override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.manage_insights) {
viewModel.onManageInsightsButtonTapped()
}
return true
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

Expand Down Expand Up @@ -198,18 +173,6 @@ class StatsFragment : DaggerFragment() {
viewModel.siteChanged.observe(this, Observer {
viewModel.refreshData()
})

viewModel.isMenuVisible.observe(this, Observer { isMenuVisible ->
isMenuVisible?.let {
menu?.findItem(R.id.manage_insights)?.isVisible = isMenuVisible
}
})

viewModel.navigationTarget.observe(this, Observer { event ->
event?.getContentIfNotHandled()?.let { target ->
navigator.navigate(activity, target)
}
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class StatsModule {
mainDispatcher,
statsSiteProvider,
useCases,
{ statsStore.getInsights(statsSiteProvider.siteModel) },
{ statsStore.getAddedInsights(statsSiteProvider.siteModel) },
uiModelMapper::mapInsights
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class StatsViewAllFragment : DaggerFragment() {
super.onSaveInstanceState(outState)
}

private fun initializeViews(savedInstanceState: Bundle?) {
private fun initializeViews(savedInstanceState: Bundle?) {
val layoutManager = LinearLayoutManager(activity, LinearLayoutManager.VERTICAL, false)

savedInstanceState?.getParcelable<Parcelable>(listStateKey)?.let {
Expand All @@ -98,10 +98,10 @@ class StatsViewAllFragment : DaggerFragment() {
viewModel.onPullToRefresh()
}

select_next_date.setOnClickListener {
nextDateButton.setOnClickListener {
viewModel.onNextDateSelected()
}
select_previous_date.setOnClickListener {
previousDateButton.setOnClickListener {
viewModel.onPreviousDateSelected()
}
}
Expand Down Expand Up @@ -174,8 +174,8 @@ class StatsViewAllFragment : DaggerFragment() {
if (it != null) {
recyclerView.visibility = if (it is StatsBlock.Success) View.VISIBLE else View.GONE
loadingContainer.visibility = if (it is StatsBlock.Loading) View.VISIBLE else View.GONE
actionable_error_view.visibility = if (it is StatsBlock.Error) View.VISIBLE else View.GONE
actionable_empty_view.visibility = if (it is StatsBlock.EmptyBlock) View.VISIBLE else View.GONE
statsErrorView.visibility = if (it is StatsBlock.Error) View.VISIBLE else View.GONE
statsEmptyView.visibility = if (it is StatsBlock.EmptyBlock) View.VISIBLE else View.GONE
when (it) {
is StatsBlock.Success -> {
loadData(recyclerView, prepareLayout(it.data, it.type))
Expand All @@ -184,7 +184,7 @@ class StatsViewAllFragment : DaggerFragment() {
loadData(loadingRecyclerView, prepareLayout(it.data, it.type))
}
is StatsBlock.Error -> {
actionable_error_view.button.setOnClickListener {
statsErrorView.button.setOnClickListener {
viewModel.onRetryClick()
}
}
Expand All @@ -202,14 +202,14 @@ class StatsViewAllFragment : DaggerFragment() {
if (date_selection_toolbar.visibility != dateSelectorVisibility) {
date_selection_toolbar.visibility = dateSelectorVisibility
}
selected_date.text = dateSelectorUiModel?.date ?: ""
selectedDateTextView.text = dateSelectorUiModel?.date ?: ""
val enablePreviousButton = dateSelectorUiModel?.enableSelectPrevious == true
if (select_previous_date.isEnabled != enablePreviousButton) {
select_previous_date.isEnabled = enablePreviousButton
if (previousDateButton.isEnabled != enablePreviousButton) {
previousDateButton.isEnabled = enablePreviousButton
}
val enableNextButton = dateSelectorUiModel?.enableSelectNext == true
if (select_next_date.isEnabled != enableNextButton) {
select_next_date.isEnabled = enableNextButton
if (nextDateButton.isEnabled != enableNextButton) {
nextDateButton.isEnabled = enableNextButton
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import org.wordpress.android.analytics.AnalyticsTracker.Stat.STATS_PERIOD_WEEKS_
import org.wordpress.android.analytics.AnalyticsTracker.Stat.STATS_PERIOD_YEARS_ACCESSED
import org.wordpress.android.modules.UI_THREAD
import org.wordpress.android.ui.pages.SnackbarMessageHolder
import org.wordpress.android.ui.stats.refresh.NavigationTarget.ViewInsightsManagement
import org.wordpress.android.ui.stats.refresh.lists.BaseListUseCase
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.StatsSection.DAYS
Expand All @@ -29,7 +28,6 @@ import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.util.NetworkUtilsWrapper
import org.wordpress.android.util.analytics.AnalyticsTrackerWrapper
import org.wordpress.android.util.mergeNotNull
import org.wordpress.android.viewmodel.Event
import org.wordpress.android.viewmodel.ScopedViewModel
import javax.inject.Inject
import javax.inject.Named
Expand All @@ -47,9 +45,6 @@ class StatsViewModel
private val _isRefreshing = MutableLiveData<Boolean>()
val isRefreshing: LiveData<Boolean> = _isRefreshing

private val _isMenuVisible = MutableLiveData<Boolean>()
val isMenuVisible: LiveData<Boolean> = _isMenuVisible

private var isInitialized = false

private val _showSnackbarMessage = mergeNotNull(
Expand All @@ -59,9 +54,6 @@ class StatsViewModel
)
val showSnackbarMessage: LiveData<SnackbarMessageHolder> = _showSnackbarMessage

private val _navigationTarget = MutableLiveData<Event<NavigationTarget>>()
val navigationTarget: LiveData<Event<NavigationTarget>> = _navigationTarget

val siteChanged = statsSiteProvider.siteChanged

private val _toolbarHasShadow = MutableLiveData<Boolean>()
Expand Down Expand Up @@ -117,7 +109,6 @@ class StatsViewModel
listUseCases[statsSection]?.onListSelected()

_toolbarHasShadow.value = statsSection == INSIGHTS
_isMenuVisible.value = statsSection == INSIGHTS

when (statsSection) {
INSIGHTS -> analyticsTracker.track(STATS_INSIGHTS_ACCESSED)
Expand All @@ -130,10 +121,6 @@ class StatsViewModel
}
}

fun onManageInsightsButtonTapped() {
_navigationTarget.value = Event(ViewInsightsManagement)
}

override fun onCleared() {
super.onCleared()
_showSnackbarMessage.value = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import org.wordpress.android.R
import org.wordpress.android.fluxc.store.StatsStore.StatsTypes
import org.wordpress.android.fluxc.store.StatsStore.StatsType
import org.wordpress.android.ui.pages.SnackbarMessageHolder
import org.wordpress.android.ui.stats.refresh.NavigationTarget
import org.wordpress.android.ui.stats.refresh.lists.StatsListViewModel.UiModel
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase
import org.wordpress.android.ui.stats.refresh.lists.sections.BaseStatsUseCase.UseCaseModel
import org.wordpress.android.ui.stats.refresh.utils.StatsSiteProvider
import org.wordpress.android.util.DistinctMutableLiveData
import org.wordpress.android.util.PackageUtils
import org.wordpress.android.util.combineMap
import org.wordpress.android.util.distinct
Expand All @@ -28,13 +27,17 @@ class BaseListUseCase(
private val mainDispatcher: CoroutineDispatcher,
private val statsSiteProvider: StatsSiteProvider,
private val useCases: List<BaseStatsUseCase<*, *>>,
private val getStatsTypes: suspend () -> List<StatsTypes>,
private val mapUiModel: (useCaseModels: List<UseCaseModel>, showError: (Int) -> Unit) -> UiModel
private val getStatsTypes: suspend () -> List<StatsType>,
private val mapUiModel: (
useCaseModels: List<UseCaseModel>,
MutableLiveData<Event<NavigationTarget>>,
showError: (Int) -> Unit
) -> UiModel
) {
private val blockListData = combineMap(
useCases.associateBy { it.type }.mapValues { entry -> entry.value.liveData }
)
private val statsTypes = DistinctMutableLiveData<List<StatsTypes>>(listOf())
private val statsTypes = MutableLiveData<List<StatsType>>()
val data: MediatorLiveData<UiModel> = mergeNotNull(statsTypes, blockListData) { types, map ->
types.mapNotNull {
if (map.containsKey(it)) {
Expand All @@ -44,13 +47,14 @@ class BaseListUseCase(
}
}
}.map { useCaseModels ->
mapUiModel(useCaseModels) { message ->
mapUiModel(useCaseModels, mutableNavigationTarget) { message ->
mutableSnackbarMessage.postValue(message)
}
}.distinct()

private val mutableNavigationTarget = MutableLiveData<Event<NavigationTarget>>()
val navigationTarget: LiveData<Event<NavigationTarget>> = mergeNotNull(
useCases.map { it.navigationTarget },
useCases.map { it.navigationTarget } + mutableNavigationTarget,
distinct = false
)

Expand All @@ -70,7 +74,7 @@ class BaseListUseCase(
loadData(true, forced)
}

suspend fun refreshTypes(): List<StatsTypes> {
suspend fun refreshTypes(): List<StatsType> {
val items = getStatsTypes()
withContext(mainDispatcher) {
statsTypes.value = items
Expand Down Expand Up @@ -99,7 +103,6 @@ class BaseListUseCase(

fun onCleared() {
mutableSnackbarMessage.value = null
statsTypes.clear()
blockListData.value = null
useCases.forEach { it.clear() }
data.value = null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,43 @@
package org.wordpress.android.ui.stats.refresh.lists

import org.wordpress.android.fluxc.store.StatsStore.StatsTypes
import org.wordpress.android.fluxc.store.StatsStore.StatsType
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Type.CONTROL
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Type.EMPTY
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Type.ERROR
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Type.LOADING
import org.wordpress.android.ui.stats.refresh.lists.StatsBlock.Type.SUCCESS
import org.wordpress.android.ui.stats.refresh.lists.sections.BlockListItem

sealed class StatsBlock(val type: Type, open val statsTypes: StatsTypes, open val data: List<BlockListItem>) {
sealed class StatsBlock(val type: Type, open val data: List<BlockListItem>) {
enum class Type {
SUCCESS,
ERROR,
EMPTY,
LOADING
LOADING,
CONTROL
}

data class Success(
override val statsTypes: StatsTypes,
val statsType: StatsType,
override val data: List<BlockListItem>
) : StatsBlock(SUCCESS, statsTypes, data)
) : StatsBlock(SUCCESS, data)

data class Error(
override val statsTypes: StatsTypes,
val statsType: StatsType,
override val data: List<BlockListItem> = listOf()
) : StatsBlock(ERROR, statsTypes, data)
) : StatsBlock(ERROR, data)

data class EmptyBlock(
override val statsTypes: StatsTypes,
val statsType: StatsType,
override val data: List<BlockListItem>
) : StatsBlock(EMPTY, statsTypes, data)
) : StatsBlock(EMPTY, data)

data class Loading(
override val statsTypes: StatsTypes,
val statsType: StatsType,
override val data: List<BlockListItem>
) : StatsBlock(LOADING, statsTypes, data)
) : StatsBlock(LOADING, data)

data class Control(
override val data: List<BlockListItem>
) : StatsBlock(CONTROL, data)
}
Loading