Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product list selection #7971

Merged
merged 57 commits into from
Dec 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1bf36e0
add product selection menu
Dec 1, 2022
b6ed2f3
products selection with SelectionTracker
Dec 1, 2022
0f0406f
revert selection hotspot
Dec 1, 2022
66ce41a
update list item lookups
Dec 1, 2022
37fa0fa
fix space warning
Dec 1, 2022
fc3665e
fix configuration change
Dec 1, 2022
b3d18f5
refactor product selection
Dec 1, 2022
59b59fd
Merge remote-tracking branch 'origin/trunk' into issue/7929-product-l…
Dec 1, 2022
7da6f66
toolbar style
Dec 2, 2022
69a36fb
fix menu style
Dec 2, 2022
2a742da
add mutable multi selection predicate
Dec 5, 2022
f52a0a5
delay multi selection
Dec 5, 2022
78935ba
Merge remote-tracking branch 'origin/trunk' into issue/7929-product-l…
Dec 6, 2022
025e609
Merge pull request #7990 from woocommerce/fix/list-multiselect-top-fr…
wzieba Dec 6, 2022
5dc10c9
feat: update prices of selected products
wzieba Dec 6, 2022
cd7c159
style: remove boilerplate from xml layout
wzieba Dec 7, 2022
8c25ccb
feat: add success/error snackbar messages
wzieba Dec 7, 2022
b75acf1
refactor: orchestrate showing dialog via VM
wzieba Dec 7, 2022
33f05da
feat: bulk update products status
wzieba Dec 7, 2022
e6995b3
fix: do not crash if user didnt choose new status
wzieba Dec 7, 2022
23b476e
clear selection on browsing state
Dec 7, 2022
6816693
move logic to viewmodel
Dec 7, 2022
1b4d11b
restore product selection
Dec 7, 2022
a077315
ProductListState as enum
Dec 7, 2022
3bb394e
pagination with selection
Dec 7, 2022
986fada
fix detekt warnings
Dec 7, 2022
bff7622
fix add button visible on configuration change
Dec 7, 2022
e601aaf
refactor ProductSelectionItemKeyProvider
Dec 7, 2022
01ec9ad
Merge remote-tracking branch 'origin/issue/7929-product-list-selectio…
wzieba Dec 7, 2022
8b3170c
fix: rename onUpdatePriceClicked to onUpdatePriceConfirmed
wzieba Dec 8, 2022
175309c
Merge remote-tracking branch 'origin/issue/7933-bulk-product-price-up…
wzieba Dec 8, 2022
c3c74a2
style: improve readability of product status update method
wzieba Dec 8, 2022
9b83c7b
feat: add tracks events for prduct bulk update
wzieba Dec 8, 2022
c99f9e3
feat: add event for select all button
wzieba Dec 8, 2022
0604787
test: Add missing test cases for bulk update analytics tracking code
wzieba Dec 8, 2022
f34bd05
remove unnecessary menu styling
Dec 8, 2022
2175d24
fix selection appearing after config change
Dec 8, 2022
b64701e
fix crash after calling collapseActionView multiple times
Dec 8, 2022
df2bb3a
keep toolbar collapsed while searching
Dec 8, 2022
8589e11
ignore field clean up calls
Dec 8, 2022
53d415f
fix detekt spacing warning
Dec 8, 2022
bc3de29
show refreshing state while updating products
Dec 9, 2022
bcea90d
trigger events with delay
Dec 9, 2022
6e360e0
use collapse/expand default constant
Dec 9, 2022
74cfef8
fix detekt warnings
Dec 9, 2022
dabcaaa
refactor to use List instead of Collection
Dec 9, 2022
6ad0d35
unit test bulk update price
Dec 9, 2022
14f0b68
fix indentation
Dec 9, 2022
b32af47
Merge branch 'issue/7933-bulk-product-price-update' into issue/7932-b…
Dec 9, 2022
af8e85e
refactor improving readability
Dec 9, 2022
479c245
add unit tests to bulk update products' statuses
Dec 9, 2022
146b1b3
Merge branch 'issue/7932-bulk-product-status-update' into issue/8004-…
Dec 9, 2022
893e70c
Merge pull request #8005 from woocommerce/issue/8004-add-bulk-product…
atorresveiga Dec 9, 2022
7f3537e
prevent detail navigation
Dec 9, 2022
84268d1
Merge pull request #8000 from woocommerce/issue/7932-bulk-product-sta…
atorresveiga Dec 9, 2022
e01a491
Merge pull request #7997 from woocommerce/issue/7933-bulk-product-pri…
atorresveiga Dec 9, 2022
7987e34
Merge branch 'issue/7929-product-list-selection' of https://github.co…
Dec 9, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,11 @@ enum class AnalyticsEvent(val siteless: Boolean = false) {
PRODUCT_LIST_SORTING_OPTION_SELECTED,
PRODUCT_LIST_ADD_PRODUCT_BUTTON_TAPPED,
ADD_PRODUCT_PRODUCT_TYPE_SELECTED,
PRODUCT_LIST_BULK_UPDATE_REQUESTED,
PRODUCT_LIST_BULK_UPDATE_CONFIRMED,
PRODUCT_LIST_BULK_UPDATE_SUCCESS,
PRODUCT_LIST_BULK_UPDATE_FAILURE,
PRODUCT_LIST_BULK_UPDATE_SELECT_ALL_TAPPED,

// -- Product detail
PRODUCT_DETAIL_LOADED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,12 @@ class AnalyticsTracker private constructor(private val context: Context) {
const val VALUE_STEP_WEB_CHECKOUT = "web_checkout"
const val VALUE_STEP_STORE_INSTALLATION = "store_installation"

// -- Products bulk update
const val KEY_PROPERTY = "property"
const val VALUE_PRICE = "price"
const val VALUE_STATUS = "status"
const val KEY_SELECTED_PRODUCTS_COUNT = "selected_products_count"

var sendUsageStats: Boolean = true
set(value) {
if (value != field) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.map

private const val EXPAND_COLLAPSE_ANIMATION_DURATION_MILLIS = 300L
const val EXPAND_COLLAPSE_ANIMATION_DURATION_MILLIS = 300L

fun View.show() {
this.visibility = View.VISIBLE
Expand All @@ -37,7 +37,7 @@ fun View.hide() {
this.visibility = View.GONE
}

fun View.expand(duration: Long = 300L) {
fun View.expand(duration: Long = EXPAND_COLLAPSE_ANIMATION_DURATION_MILLIS) {
if (!this.isVisible) {
this.visibility = View.VISIBLE
this.measure(
Expand Down Expand Up @@ -68,7 +68,7 @@ fun View.expand(duration: Long = 300L) {
}
}

fun View.collapse(duration: Long = 300L) {
fun View.collapse(duration: Long = EXPAND_COLLAPSE_ANIMATION_DURATION_MILLIS) {
if (this.isVisible) {
val initialHeight = this.measuredHeight
val view = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,16 @@ abstract class TopLevelFragment : BaseFragment, TopLevelFragmentView {
}
}
}

fun onListSelectionActiveChanged(isActive: Boolean, expandToolbar: Boolean) {
(activity as? MainActivity)?.let {
if (isActive) {
it.enableToolbarExpansion(false)
it.expandToolbar(expand = false, animate = false)
} else {
it.enableToolbarExpansion(expandToolbar)
it.expandToolbar(expand = expandToolbar, expandToolbar)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.woocommerce.android.ui.products

import androidx.recyclerview.selection.SelectionTracker

class MutableMultipleSelectionPredicate<K : Any> : SelectionTracker.SelectionPredicate<K>() {
var selectMultiple = true

override fun canSetStateForKey(key: K, nextState: Boolean): Boolean = true

override fun canSetStateAtPosition(position: Int, nextState: Boolean): Boolean = true

override fun canSelectMultiple(): Boolean = selectMultiple
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.woocommerce.android.ui.products

import android.view.MotionEvent
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.recyclerview.selection.ItemDetailsLookup
import androidx.recyclerview.widget.RecyclerView
import com.woocommerce.android.R
import com.woocommerce.android.databinding.ProductListItemBinding
Expand Down Expand Up @@ -40,15 +38,4 @@ class ProductItemViewHolder(val viewBinding: ProductListItemBinding) :
setOnClickListener { onItemDeleted.invoke(product) }
}
}

/**
* Method to return details associated with a user selection
*/
fun getItemDetails() =
object : ItemDetailsLookup.ItemDetails<Long>() {
@Suppress("DEPRECATION")
override fun getPosition() = adapterPosition
override fun getSelectionKey() = itemId
override fun inSelectionHotspot(e: MotionEvent) = true
}
}
Loading