Skip to content

Commit

Permalink
Merge branch 'trunk' into 12223-error-screens-ui-update
Browse files Browse the repository at this point in the history
  • Loading branch information
AnirudhBhat authored Aug 19, 2024
2 parents 2bab66c + 3107fb1 commit 5052dc6
Show file tree
Hide file tree
Showing 72 changed files with 2,668 additions and 2,383 deletions.
2 changes: 1 addition & 1 deletion .configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"project_name": "woocommerce-android",
"branch": "trunk",
"pinned_hash": "b76cc454e9bb5f58a6bb59de6232b20f477e8014",
"pinned_hash": "126ffacbbfc7abf1f4bf14670d72418846f04673",
"files_to_copy": [
{
"file": "android/WCAndroid/gradle.properties",
Expand Down
Binary file modified .configure-files/gradle.properties.enc
Binary file not shown.
10 changes: 8 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,14 @@ Closes: #
### Images/gif
<!-- Include before and after images or gifs when appropriate. -->


- [ ] I have considered adding unit tests for this change. If I decided not to add them, I have provided a brief explanation below (optional):
- [ ] I have considered if this change warrants release notes and have added them to `RELEASE-NOTES.txt` if necessary. Use the "[Internal]" label for non-user-facing changes.

## Reviewer (or Author, in the case of optional code reviews):

Please make sure these conditions are met before approving the PR, or request changes if the PR needs improvement:

- [ ] The PR is small and has a clear, single focus, or a valid explanation is provided in the description. If needed, please request to split it into smaller PRs.
- [ ] Ensure Adequate Unit Test Coverage: The changes are reasonably covered by unit tests or an explanation is provided in the PR description.
- [ ] Manual Testing: The author listed all the tests they ran, including smoke tests when needed (e.g., for refactorings). The reviewer confirmed that the PR works as expected on all devices (phone/tablet) and no regressions are added.

<!-- Pull request guidelines: https://github.com/woocommerce/woocommerce-android/blob/develop/docs/pull-request-guidelines.md -->
6 changes: 6 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
20.0
-----
- [*] Fixed missing pictures in card reader tutorial on tablets [https://github.com/woocommerce/woocommerce-android/pull/12274]
- [*] Disable QR code scanning from login flow [https://github.com/woocommerce/woocommerce-android/pull/12303]
- [*] Fixed the hidden “Write with AI” issue that occurs when the keyboard is open. [https://github.com/woocommerce/woocommerce-android/pull/12311]
- [*] Allowed collecting card-present payments for orders with `failed` status [https://github.com/woocommerce/woocommerce-android/pull/12349]
- [*] [Internal] [Login] Switched back to using the `/token` endpoint for WordPress.com authentication, this fixes an issue where the SMS OTP is not triggered automatically after submitting the password [https://github.com/woocommerce/woocommerce-android/pull/12319]
- [*] [Internal] [WEAR] Introduces Sentry support to the Wear app


19.9
-----
Expand All @@ -15,6 +20,7 @@
- [*****] [Internal] Update Androidx-fragment from 1.6.2 to 1.8.2 [https://github.com/woocommerce/woocommerce-android/pull/12231]
- [*****] [Internal] Update Material to 1.12.0 and Transition to 1.5.1 [https://github.com/woocommerce/woocommerce-android/pull/12237]
- [*****] [Internal] Update Stripe Terminal SDK from 3.1.1 to 3.7.1 [https://github.com/woocommerce/woocommerce-android/pull/12239]
- [*] [Login] Fixed an issue with the "send SMS" button during the 2FA login [https://github.com/woocommerce/woocommerce-android/pull/12306]
- [***] Fix logic behind handling enabled/disabled states of "+ Add coupon" and "+ Add discount" buttons in the Order creation/edition flow [https://github.com/woocommerce/woocommerce-android/pull/12263].

19.8
Expand Down
7 changes: 0 additions & 7 deletions WooCommerce-Wear/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ sentry {
(if enabled in WCCrashLoggingDataProvider).
*/
ignoredBuildTypes = ["debug"]

/* Additional source directories to be included in the source context. For now, manually:
https://github.com/getsentry/sentry-android-gradle-plugin/issues/685
*/
additionalSourceDirsForSourceContext = [
'../libs/cardreader/src/main/java',
]
}

def versionProperties = loadPropertiesFromFile(file("${rootDir}/version.properties"))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
package com.woocommerce.android.app

import android.app.Application
import com.automattic.android.tracks.crashlogging.CrashLogging
import com.yarolegovich.wellsql.WellSql
import dagger.Lazy
import dagger.hilt.android.HiltAndroidApp
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode
import org.wordpress.android.fluxc.persistence.WellSqlConfig
import org.wordpress.android.fluxc.persistence.WellSqlConfig.Companion.ADDON_WOOCOMMERCE
import org.wordpress.android.fluxc.utils.ErrorUtils.OnUnexpectedError
import javax.inject.Inject

@HiltAndroidApp
open class WooCommerceWear : Application() {

@Inject
lateinit var crashLogging: Lazy<CrashLogging>

override fun onCreate() {
super.onCreate()
WellSql.init(WellSqlConfig(applicationContext, ADDON_WOOCOMMERCE))
crashLogging.get().initialize()
}

@Suppress("unused")
@Subscribe(threadMode = ThreadMode.MAIN)
fun onUnexpectedError(event: OnUnexpectedError) {
with(event) {
crashLogging.get().sendReport(exception = exception, message = "FluxC: ${exception.message}: $description")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WCWearCrashLoggingDataProvider @Inject constructor(
private val crashLoggingUser = MutableStateFlow(accountStore.account?.toCrashLoggingUser())

override val user: Flow<CrashLoggingUser?> = crashLoggingUser
override val sentryDSN: String = BuildConfig.SENTRY_DSN
override val sentryDSN: String = BuildConfig.WEAR_SENTRY_DSN
override val buildType = BuildConfig.BUILD_TYPE
override val enableCrashLoggingLogs = BuildConfig.DEBUG
override val releaseName: ReleaseName = if (BuildConfig.DEBUG) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ sealed class AppSettings<T> {
override val key = this::class.simpleName.orEmpty()

override var value: Boolean
get() = PreferenceUtils.getBoolean(preferences, key, false)
get() = PreferenceUtils.getBoolean(preferences, key, true)
set(value) = PreferenceUtils.setBoolean(preferences, key, value)
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.woocommerce.android.wear.settings

import android.content.Context
import androidx.preference.PreferenceManager
import androidx.preference.PreferenceManager.getDefaultSharedPreferences
import com.google.android.gms.wearable.DataMap
import com.google.gson.Gson
import com.woocommerce.android.wear.settings.AppSettings.CrashReportEnabledSettings
Expand All @@ -14,8 +14,7 @@ class SettingsRepository @Inject constructor(
) {
private val gson by lazy { Gson() }

private val preferences
get() = PreferenceManager.getDefaultSharedPreferences(appContext)
private val preferences by lazy { getDefaultSharedPreferences(appContext) }

val crashReportEnabled: CrashReportEnabledSettings
get() = CrashReportEnabledSettings(preferences)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.woocommerce.android.wear.phone.PhoneConnectionRepository
import com.woocommerce.android.wear.ui.login.FetchSiteData.LoginRequestState.Logged
import com.woocommerce.android.wear.ui.login.FetchSiteData.LoginRequestState.Timeout
import com.woocommerce.android.wear.ui.login.FetchSiteData.LoginRequestState.Waiting
import com.woocommerce.commons.MessagePath.REQUEST_APP_SETTINGS
import com.woocommerce.commons.MessagePath.REQUEST_SITE
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject
Expand All @@ -15,6 +16,7 @@ class FetchSiteData @Inject constructor(
) {
suspend operator fun invoke(): Flow<LoginRequestState> {
if (phoneRepository.isPhoneConnectionAvailable()) {
phoneRepository.sendMessage(REQUEST_APP_SETTINGS)
phoneRepository.sendMessage(REQUEST_SITE)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ data class Product(
val isConfigurable: Boolean = false,
val minAllowedQuantity: Int?,
val maxAllowedQuantity: Int?,
val bundleMinSize: Float?,
val bundleMaxSize: Float?,
val groupOfQuantity: Int?,
val combineVariationQuantities: Boolean?
) : Parcelable, IProduct {
Expand Down Expand Up @@ -585,6 +587,8 @@ fun WCProductModel.toAppModel(): Product {
isConfigurable = isConfigurable,
minAllowedQuantity = this.getMinAllowedQuantity(),
maxAllowedQuantity = this.maxAllowedQuantity(),
bundleMinSize = this.bundleMinSize,
bundleMaxSize = this.bundleMaxSize,
groupOfQuantity = this.groupOfQuantity(),
combineVariationQuantities = this.combineVariationQuantities
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ enum class HelpOrigin(private val stringValue: String) {
ORDERS_LIST("origin:orders-list"),
BLAZE_CAMPAIGN_CREATION("origin:blaze-native-campaign-creation"),
CONNECTIVITY_TOOL("origin:connectivity-tool"),
APPLICATION_PASSWORD_TUTORIAL("origin:application-password-tutorial");
APPLICATION_PASSWORD_TUTORIAL("origin:application-password-tutorial"),
POS("origin:point-of-sale");

override fun toString(): String {
return stringValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ enum class CampaignStatusUi(
statusDisplayText = R.string.blaze_campaign_status_canceled,
textColor = R.color.blaze_campaign_status_rejected_text,
backgroundColor = R.color.blaze_campaign_status_rejected_background
),
Suspended(
statusDisplayText = R.string.blaze_campaign_status_suspended,
textColor = R.color.blaze_campaign_status_suspended_text,
backgroundColor = R.color.blaze_campaign_status_suspended_background
);

companion object {
Expand All @@ -63,6 +68,7 @@ enum class CampaignStatusUi(
"scheduled" -> Scheduled
"active" -> Active
"rejected" -> Rejected
"suspended" -> Suspended
"canceled" -> Canceled
"finished" -> Completed
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import com.woocommerce.android.ui.products.GetBundledProducts
import com.woocommerce.android.ui.products.ProductType
import com.woocommerce.android.ui.products.details.ProductDetailRepository
import kotlinx.coroutines.flow.first
import org.wordpress.android.fluxc.model.WCMetaData
import org.wordpress.android.fluxc.model.get
import javax.inject.Inject

class GetProductRules @Inject constructor(
Expand All @@ -30,11 +28,7 @@ class GetProductRules @Inject constructor(
val builder = ProductRules.Builder().apply {
productType = ProductType.BUNDLE
}
productDetailRepository.getProductMetadata(product.remoteId)?.let { list ->
val maxSize = list[WCMetaData.BundleMetadataKeys.BUNDLE_MAX_SIZE]?.valueAsString?.toFloatOrNull()
val minSize = list[WCMetaData.BundleMetadataKeys.BUNDLE_MIN_SIZE]?.valueAsString?.toFloatOrNull()
builder.setQuantityRules(minSize, maxSize)
}
builder.setQuantityRules(quantityMin = product.bundleMinSize, quantityMax = product.bundleMaxSize)
getBundledProducts(product.remoteId).first().forEach { bundledProduct ->
builder.setChildQuantityRules(
itemId = bundledProduct.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import com.woocommerce.android.extensions.WOOCOMMERCE_BOOKINGS_PAYMENT_TYPE
import com.woocommerce.android.extensions.WOOCOMMERCE_PAYMENTS_PAYMENT_TYPE
import com.woocommerce.android.model.Order
import com.woocommerce.android.model.Order.Status.Custom
import com.woocommerce.android.model.Order.Status.Failed
import com.woocommerce.android.model.Order.Status.OnHold
import com.woocommerce.android.model.Order.Status.Pending
import com.woocommerce.android.model.Order.Status.Processing
Expand Down Expand Up @@ -44,6 +45,7 @@ class CardReaderPaymentCollectibilityChecker @Inject constructor(
Pending,
Processing,
OnHold,
Custom(Order.Status.AUTO_DRAFT)
Custom(Order.Status.AUTO_DRAFT),
Failed,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,24 @@ import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import com.woocommerce.android.R
import com.woocommerce.android.databinding.FragmentCardReaderTutorialViewpagerItemBinding
import com.woocommerce.android.extensions.hide
import org.wordpress.android.util.DisplayUtils
import com.woocommerce.android.util.UiHelpers

/**
* Displays a single image and text label in the card reader tutorial view pager
*/
class CardReaderTutorialViewPagerItemFragment : Fragment(R.layout.fragment_card_reader_tutorial_viewpager_item) {
class CardReaderTutorialViewPagerItemFragment :
Fragment(R.layout.fragment_card_reader_tutorial_viewpager_item) {

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
arguments?.let { args ->
val binding = FragmentCardReaderTutorialViewpagerItemBinding.bind(view)
binding.labelTextView.setText(args.getInt(ARG_LABEL_ID))
binding.detailTextView.setText(args.getInt(ARG_DETAIL_ID))

// hide images in landscape
if (DisplayUtils.isLandscape(context)) {
binding.imageView.hide()
} else {
binding.imageView.setImageResource(args.getInt(ARG_DRAWABLE_ID))
}
UiHelpers.setImageOrHideInLandscapeOnCompactScreenHeightSizeClass(
binding.imageView,
args.getInt(ARG_DRAWABLE_ID)
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ object ProductHelper {
parentId = 0,
minAllowedQuantity = null,
maxAllowedQuantity = null,
bundleMinSize = null,
bundleMaxSize = null,
groupOfQuantity = null,
combineVariationQuantities = null
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ class ProductDetailRepository @Inject constructor(
}
}

fun getProductMetadata(remoteProductId: Long): List<WCMetaData>? {
return getCachedWCProductModel(remoteProductId)?.parsedMetaData ?: return null
suspend fun getProductMetadata(remoteProductId: Long): List<WCMetaData> {
return productStore.getProductMetaData(selectedSite.get(), remoteProductId)
}

@SuppressWarnings("unused")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class ProductFilterListViewModel @Inject constructor(
STOCK_STATUS,
resourceProvider.getString(R.string.product_stock_status),
addDefaultFilterOption(
CoreProductStockStatus.values().map {
CoreProductStockStatus.FILTERABLE_VALUES.map {
FilterListOptionItemUiModel.DefaultFilterListOptionItemUiModel(
resourceProvider.getString(ProductStockStatus.fromString(it.value).stringResource),
filterOptionItemValue = it.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.semantics.contentDescription
import androidx.compose.ui.semantics.semantics
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
Expand Down Expand Up @@ -316,9 +319,15 @@ private fun ProductItem(
canRemoveItems: Boolean,
onRemoveClicked: (item: WooPosCartState.Body.WithItems.Item) -> Unit
) {
val itemContentDescription = stringResource(
id = R.string.woopos_cart_item_content_description,
item.name,
item.price
)
Card(
modifier = modifier
.height(64.dp),
.height(64.dp)
.semantics { contentDescription = itemContentDescription },
elevation = 4.dp,
shape = RoundedCornerShape(8.dp),
) {
Expand All @@ -334,8 +343,8 @@ private fun ProductItem(
fallback = ColorPainter(WooPosTheme.colors.loadingSkeleton),
error = ColorPainter(WooPosTheme.colors.loadingSkeleton),
placeholder = ColorPainter(WooPosTheme.colors.loadingSkeleton),
contentDescription = stringResource(R.string.woopos_product_image_description),
contentScale = ContentScale.Crop,
contentDescription = null,
modifier = Modifier.size(64.dp)
)

Expand All @@ -349,24 +358,34 @@ private fun ProductItem(
style = MaterialTheme.typography.body1,
fontWeight = FontWeight.SemiBold,
maxLines = 1,
overflow = TextOverflow.Ellipsis
overflow = TextOverflow.Ellipsis,
modifier = Modifier.clearAndSetSemantics { }
)
Spacer(modifier = Modifier.height(4.dp.toAdaptivePadding()))
Text(text = item.price, style = MaterialTheme.typography.body1)
Text(
text = item.price,
style = MaterialTheme.typography.body1,
modifier = Modifier.clearAndSetSemantics { }
)
}

if (canRemoveItems) {
Spacer(modifier = Modifier.width(8.dp.toAdaptivePadding()))

val removeButtonContentDescription = stringResource(
id = R.string.woopos_remove_item_button_from_cart_content_description,
item.name
)
IconButton(
onClick = { onRemoveClicked(item) },
modifier = Modifier
.size(24.dp)
.semantics { contentDescription = removeButtonContentDescription }
) {
Icon(
painter = painterResource(id = R.drawable.ic_pos_remove_cart_item),
tint = MaterialTheme.colors.onBackground,
contentDescription = "Remove item",
contentDescription = null,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import com.woocommerce.android.ui.woopos.home.WooPosParentToChildrenEventReceive
import com.woocommerce.android.ui.woopos.home.cart.WooPosCartStatus.CHECKOUT
import com.woocommerce.android.ui.woopos.home.cart.WooPosCartStatus.EDITABLE
import com.woocommerce.android.ui.woopos.home.cart.WooPosCartStatus.EMPTY
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsEvent
import com.woocommerce.android.ui.woopos.util.analytics.WooPosAnalyticsTracker
import com.woocommerce.android.ui.woopos.util.format.WooPosFormatPrice
import com.woocommerce.android.viewmodel.ResourceProvider
import com.woocommerce.android.viewmodel.getStateFlow
Expand All @@ -32,6 +34,7 @@ class WooPosCartViewModel @Inject constructor(
private val getProductById: WooPosGetProductById,
private val resourceProvider: ResourceProvider,
private val formatPrice: WooPosFormatPrice,
private val analyticsTracker: WooPosAnalyticsTracker,
savedState: SavedStateHandle,
) : ViewModel() {
private val _state = savedState.getStateFlow(
Expand Down Expand Up @@ -127,6 +130,7 @@ class WooPosCartViewModel @Inject constructor(
)
)
}
analyticsTracker.track(WooPosAnalyticsEvent.Event.ItemAddedToCart)
}

is ParentToChildrenEvent.OrderSuccessfullyPaid -> {
Expand Down
Loading

0 comments on commit 5052dc6

Please sign in to comment.