Skip to content

Commit

Permalink
Merge branch 'trunk' into 12928-woo-pos---payments-onboarding-remove-…
Browse files Browse the repository at this point in the history
…local-ff
  • Loading branch information
kidinov committed Nov 21, 2024
2 parents dcc1be6 + 81b12c9 commit 503f98d
Show file tree
Hide file tree
Showing 30 changed files with 1,516 additions and 378 deletions.
4 changes: 3 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
*** PLEASE FOLLOW THIS FORMAT: [<priority indicator, more stars = higher priority>] <description> [<PR URL>]
*** Use [*****] to indicate smoke tests of all critical flows should be run on the final APK before release (e.g. major library or targetSdk updates).
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
-----
21.2
- [Internal] Changed a way how authenticated web view opened in the IPP flows [https://github.com/woocommerce/woocommerce-android/pull/12908]
- [Internal][POS] Onboarding to the IPP now is part of the POS [https://github.com/woocommerce/woocommerce-android/pull/12942]
- [*] Fixed an inconsistent state while refreshing the orders list [https://github.com/woocommerce/woocommerce-android/pull/12948]
-----
- [**][Payments] Fixed a bug when IPP onboarding was not possible to finish from the app [https://github.com/woocommerce/woocommerce-android/pull/12917]
- [*] Fixed shipping lines being editable at all states [https://github.com/woocommerce/woocommerce-android/pull/12890]
- [*] Fixed a crash that occurred when tapping on the customer shipping address in the order details screen [https://github.com/woocommerce/woocommerce-android/pull/12920]
- [*][Payments] Fixed a bug when loading indicator was shown forever after fetching of a receipt failed [https://github.com/woocommerce/woocommerce-android/pull/12950]
- [**] Enables creating a new WP.com account during Jetpack activation flow [https://github.com/woocommerce/woocommerce-android/issues/11114]

21.1
-----
Expand Down
4 changes: 1 addition & 3 deletions WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,7 @@ static def loadPropertiesFromFile(inputFile) {
}

def isLeakCanaryEnabled() {
return project.properties.getOrDefault('enableLeakCanary', 'true') == 'true'
return developerProperties.get("enable_leak_canary") ?: true
}



apply from: '../config/gradle/build_optimization.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import com.woocommerce.android.analytics.AnalyticsTracker
import com.woocommerce.android.analytics.AnalyticsTrackerWrapper
import com.woocommerce.android.model.JetpackStatus
import com.woocommerce.android.ui.login.WPComLoginRepository
import com.woocommerce.android.util.FeatureFlag
import com.woocommerce.android.util.StringUtils
import com.woocommerce.android.viewmodel.MultiLiveEvent
import com.woocommerce.android.viewmodel.MultiLiveEvent.Event.Exit
Expand All @@ -30,7 +29,8 @@ import javax.inject.Inject
class JetpackActivationWPComEmailViewModel @Inject constructor(
savedStateHandle: SavedStateHandle,
private val wpComLoginRepository: WPComLoginRepository,
private val analyticsTrackerWrapper: AnalyticsTrackerWrapper
private val analyticsTrackerWrapper: AnalyticsTrackerWrapper,
private val stringUtils: StringUtils,
) : ScopedViewModel(savedStateHandle) {
private val navArgs: JetpackActivationWPComEmailFragmentArgs by savedStateHandle.navArgs()

Expand Down Expand Up @@ -106,10 +106,10 @@ class JetpackActivationWPComEmailViewModel @Inject constructor(
when (failure?.type) {
AuthOptionsErrorType.UNKNOWN_USER -> {
when {
!StringUtils.isValidEmail(emailOrUsername) ->
!stringUtils.isValidEmail(emailOrUsername) ->
errorMessage.value = R.string.username_not_registered_wpcom

FeatureFlag.JETPACK_FLOW_ACCOUNT_CREATION.isEnabled() -> {
else -> {
triggerEvent(
ShowMagicLinkScreen(
emailOrUsername,
Expand All @@ -119,8 +119,6 @@ class JetpackActivationWPComEmailViewModel @Inject constructor(
)
isSignup = true
}

else -> errorMessage.value = R.string.email_not_registered_wpcom
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.Divider
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
Expand All @@ -27,7 +26,6 @@ internal fun PurchasesSection(
modifier: Modifier = Modifier
) {
Column(modifier) {
Divider()
MarkComplete(
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange
Expand All @@ -45,7 +43,6 @@ internal fun PurchasesSectionLandscape(
modifier: Modifier = Modifier
) {
Column(modifier.fillMaxWidth()) {
Divider()
Row(verticalAlignment = Alignment.CenterVertically) {
MarkComplete(
markOrderComplete = markOrderComplete,
Expand Down Expand Up @@ -76,7 +73,7 @@ fun PurchasesSectionLandscapePreview() {
}

@Composable
private fun MarkComplete(
internal fun MarkComplete(
markOrderComplete: Boolean,
onMarkOrderCompleteChange: (Boolean) -> Unit,
modifier: Modifier = Modifier
Expand All @@ -102,7 +99,7 @@ private fun MarkComplete(
}

@Composable
private fun PurchaseButton(
internal fun PurchaseButton(
total: String?,
onPurchaseShippingLabel: () -> Unit,
modifier: Modifier = Modifier
Expand All @@ -127,7 +124,7 @@ private fun PurchaseButton(

@Preview
@Composable
private fun PurchasesSectionPreview() {
internal fun PurchasesSectionPreview() {
WooThemeWithBackground {
PurchasesSection(
total = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import androidx.compose.ui.unit.dp
import com.woocommerce.android.R
import com.woocommerce.android.model.Address
import com.woocommerce.android.ui.compose.animations.SkeletonView
import com.woocommerce.android.ui.compose.component.BottomSheetHandle
import com.woocommerce.android.ui.compose.theme.WooThemeWithBackground
import com.woocommerce.android.util.StringUtils
import kotlinx.coroutines.launch
Expand All @@ -55,12 +54,12 @@ fun ShipmentDetails(
scaffoldState: BottomSheetScaffoldState,
markOrderComplete: Boolean,
onMarkOrderCompleteChange: (Boolean) -> Unit,
onPurchaseShippingLabel: () -> Unit,
modifier: Modifier = Modifier,
handlerModifier: Modifier = Modifier,
) {
val scope = rememberCoroutineScope()
Column(
modifier
handlerModifier
.clickable(
onClick = {
scope.launch {
Expand All @@ -79,7 +78,16 @@ fun ShipmentDetails(
verticalArrangement = Arrangement.Center,
horizontalAlignment = Alignment.CenterHorizontally
) {
BottomSheetHandle(modifier = Modifier.padding(top = dimensionResource(R.dimen.minor_100)))
Icon(
modifier = Modifier.padding(top = dimensionResource(R.dimen.minor_100)),
painter = if (scaffoldState.bottomSheetState.isExpanded) {
painterResource(R.drawable.ic_arrow_down_26)
} else {
painterResource(R.drawable.ic_arrow_up_26)
},
contentDescription = stringResource(R.string.order_creation_expand_collapse_order_totals),
tint = colorResource(id = R.color.color_primary),
)
AnimatedVisibility(visible = scaffoldState.bottomSheetState.isCollapsed) {
Text(
text = stringResource(R.string.shipping_label_shipment_details_title),
Expand All @@ -90,16 +98,12 @@ fun ShipmentDetails(
}
}
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
ShipmentDetailsLandscape(
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
onPurchaseShippingLabel = onPurchaseShippingLabel
)
ShipmentDetailsLandscape(modifier = modifier)
} else {
ShipmentDetailsPortrait(
modifier = modifier,
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
onPurchaseShippingLabel = onPurchaseShippingLabel
onMarkOrderCompleteChange = onMarkOrderCompleteChange
)
}
}
Expand All @@ -108,7 +112,6 @@ fun ShipmentDetails(
private fun ShipmentDetailsPortrait(
markOrderComplete: Boolean,
onMarkOrderCompleteChange: (Boolean) -> Unit,
onPurchaseShippingLabel: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier) {
Expand All @@ -134,20 +137,16 @@ private fun ShipmentDetailsPortrait(
modifier = Modifier.padding(dimensionResource(R.dimen.major_100))
)
}
PurchasesSection(
total = "$120.99",
Divider()
MarkComplete(
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
onPurchaseShippingLabel = onPurchaseShippingLabel
onMarkOrderCompleteChange = onMarkOrderCompleteChange
)
}
}

@Composable
private fun ShipmentDetailsLandscape(
markOrderComplete: Boolean,
onMarkOrderCompleteChange: (Boolean) -> Unit,
onPurchaseShippingLabel: () -> Unit,
modifier: Modifier = Modifier,
) {
Column(modifier) {
Expand Down Expand Up @@ -185,12 +184,6 @@ private fun ShipmentDetailsLandscape(
)
}
}
PurchasesSectionLandscape(
total = "$120.99",
markOrderComplete = markOrderComplete,
onMarkOrderCompleteChange = onMarkOrderCompleteChange,
onPurchaseShippingLabel = onPurchaseShippingLabel
)
}
}

Expand Down Expand Up @@ -273,11 +266,7 @@ private fun OrderDetailsSectionLandscape(
fun ShipmentDetailsLandscapePreview() {
WooThemeWithBackground {
Surface {
ShipmentDetailsLandscape(
markOrderComplete = false,
onMarkOrderCompleteChange = {},
onPurchaseShippingLabel = {}
)
ShipmentDetailsLandscape()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.woocommerce.android.ui.orders.wooshippinglabels
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
Expand All @@ -12,6 +13,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.BottomSheetScaffold
import androidx.compose.material.BottomSheetScaffoldState
import androidx.compose.material.ExperimentalMaterialApi
import androidx.compose.material.Icon
import androidx.compose.material.IconButton
Expand All @@ -27,6 +29,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.dimensionResource
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -57,17 +60,52 @@ fun WooShippingLabelCreationScreen(
onPurchaseShippingLabel: () -> Unit
) {
val scaffoldState = rememberBottomSheetScaffoldState()
Box(modifier = Modifier.fillMaxSize()) {
LabelCreationScreenWithBottomSheet(
modifier = modifier,
onSelectPackageClick = onSelectPackageClick,
scaffoldState = scaffoldState
)
val elevation = if (scaffoldState.bottomSheetState.isCollapsed) { 0.dp } else { 4.dp }
Box(
modifier = Modifier
.fillMaxWidth()
.align(Alignment.BottomCenter)
) {
Surface(elevation = elevation) {
if (LocalConfiguration.current.orientation == Configuration.ORIENTATION_LANDSCAPE) {
PurchasesSectionLandscape(
total = "$34.89",
markOrderComplete = true,
onMarkOrderCompleteChange = { },
onPurchaseShippingLabel = onPurchaseShippingLabel
)
} else {
PurchaseButton(total = "$34.89", onPurchaseShippingLabel = { })
}
}
}
}
}

@OptIn(ExperimentalMaterialApi::class)
@Composable
private fun LabelCreationScreenWithBottomSheet(
modifier: Modifier = Modifier,
onSelectPackageClick: () -> Unit,
scaffoldState: BottomSheetScaffoldState
) {
BottomSheetScaffold(
sheetContent = {
val markOrderComplete = remember { mutableStateOf(false) }
ShipmentDetails(
modifier = Modifier.padding(bottom = 74.dp),
scaffoldState = scaffoldState,
markOrderComplete = markOrderComplete.value,
onMarkOrderCompleteChange = { markOrderComplete.value = it },
onPurchaseShippingLabel = onPurchaseShippingLabel
onMarkOrderCompleteChange = { markOrderComplete.value = it }
)
},
sheetPeekHeight = 64.dp,
sheetPeekHeight = 132.dp,
scaffoldState = scaffoldState,
topBar = {
TopAppBar(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ class CardReaderPaymentViewModel
errorDescription = receiptResult.exceptionOrNull()?.message ?: "Unknown error",
)
triggerEvent(ShowSnackbar(R.string.receipt_fetching_error))
onCancelPaymentFlow()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class SelectPaymentMethodFragment : BaseFragment(R.layout.fragment_select_paymen
if (findNavController().currentDestination?.id == R.id.selectPaymentMethodFragment) {
findNavController().navigate(
SelectPaymentMethodFragmentDirections
.actionSelectPaymentMethodFragmentToCardReaderPaymentFlow(
.actionWooPosSelectPaymentMethodFragmentToCardReaderPaymentFlow(
event.cardReaderFlowParam,
event.cardReaderType
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class VariationListHandler @Inject constructor(private val repository: Variation

fun getVariationsFlow(productId: Long) = repository.observeVariations(productId)

fun canLoadMore(): Boolean {
return canLoadMore
}

suspend fun fetchVariations(productId: Long, forceRefresh: Boolean = false): Result<Unit> = mutex.withLock {
// Reset the offset
offset = 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.woocommerce.android.ui.woopos.home.items

sealed class WooPosBaseViewState(
open val reloadingProductsWithPullToRefresh: Boolean
)

interface ContentViewState {
val items: List<WooPosItem>
val loadingMore: Boolean
val reloadingProductsWithPullToRefresh: Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,11 @@ sealed class WooPosItem(
val numOfVariations: Int,
val variationIds: List<Long>,
) : WooPosItem(id, name)

data class Variation(
override val id: Long,
override val name: String,
val price: String,
val imageUrl: String?,
) : WooPosItem(id, name)
}
Loading

0 comments on commit 503f98d

Please sign in to comment.