Skip to content

Commit

Permalink
Merge branch 'trunk' into feature/woo-2.0-brand-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano authored Jan 30, 2025
2 parents 118e164 + fe7f276 commit 5f8b670
Show file tree
Hide file tree
Showing 44 changed files with 227 additions and 415 deletions.
2 changes: 1 addition & 1 deletion .buildkite/commands/lint.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -u

.buildkite/commands/restore-cache.sh
"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

echo "--- 🧹 Linting"
./gradlew :WooCommerce:lintJalapenoDebug
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/commands/prototype-build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

.buildkite/commands/restore-cache.sh
"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

APP_TO_BUILD="${1?You need to specify the app to build, WooCommerce or WooCommerce-Wear}"

Expand Down
4 changes: 1 addition & 3 deletions .buildkite/commands/restore-cache.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/bin/bash

set -e
#!/bin/bash -e

echo "--- 💾 Restore Cache"
restore_gradle_dependency_cache || true
2 changes: 1 addition & 1 deletion .buildkite/commands/run-instrumented-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

.buildkite/commands/restore-cache.sh
"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

echo "--- :rubygems: Setting up Gems"
install_gems
Expand Down
2 changes: 1 addition & 1 deletion .buildkite/commands/run-unit-tests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -eu

.buildkite/commands/restore-cache.sh
"$(dirname "${BASH_SOURCE[0]}")/restore-cache.sh"

echo "--- 🧪 Testing"
set +e
Expand Down
36 changes: 2 additions & 34 deletions .buildkite/commands/save-cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,8 @@

set -euo pipefail

echo "--- :rubygems: Setting up Gems"
install_gems

echo "--- :closed_lock_with_key: Installing Secrets"
bundle exec fastlane run configure_apply

# .buildkite/commands/prototype-build.sh -> build_and_upload_prototype_build
# -> prototype_flavor = 'Jalapeno'
# -> prototype_build_type = 'Debug'
echo "--- 🛠 Download Mobile App Dependencies [Assemble Mobile App]"
./gradlew :WooCommerce:assembleJalapenoDebug
echo ""

# .buildkite/commands/prototype-build.sh -> build_and_upload_prototype_build
# -> prototype_flavor = 'Jalapeno'
# -> prototype_build_type = 'Debug'
echo "--- 🛠 Download Wear App Dependencies [Assemble Wear App]"
./gradlew :WooCommerce-Wear:assembleJalapenoDebug
echo ""

# .buildkite/commands/lint.sh -> ./gradlew :WooCommerce:lintJalapenoDebug
echo "--- 🧹 Download Lint Dependencies [Lint Mobile App]"
./gradlew :WooCommerce:lintJalapenoDebug
echo ""

# .buildkite/commands/run-unit-tests.sh -> ./gradlew testJalapenoDebugUnitTest testDebugUnitTest
echo "--- 🧪 Download Unit Test Dependencies [Assemble Unit Tests]"
./gradlew assembleJalapenoDebugUnitTest assembleDebugUnitTest
echo ""

# .buildkite/commands/run-instrumented-tests.sh -> build_and_instrumented_test
# -> gradle(tasks: %w[assembleVanillaDebug assembleVanillaDebugAndroidTest])
echo "--- 🧪 Download Android Test Dependencies [Assemble Android Tests]"
./gradlew assembleJalapenoDebugAndroidTest
echo "--- 📦 Download Dependencies"
./gradlew downloadDependencies
echo ""

echo "--- 💾 Save Cache"
Expand Down
6 changes: 2 additions & 4 deletions .buildkite/schedules/dependency-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ agents:
queue: "android"

steps:
- label: "dependency cache"
command: |
echo "--- 💾 Download and Cache Dependencies"
.buildkite/commands/save-cache.sh
- label: "💾 Download and Cache Dependencies"
command: .buildkite/commands/save-cache.sh
plugins: [$CI_TOOLKIT]

notify:
Expand Down
2 changes: 2 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*** For entries which are touching the Android Wear app's, start entry with `[WEAR]` too.
21.6
-----
- [*] Updated tablet detection logic to consider both width and height dimensions, enhancing compatibility with larger phones and tablets, particularly in landscape mode [https://github.com/woocommerce/woocommerce-android/pull/13228]
- [**] The UK customers have access to the POS now [https://github.com/woocommerce/woocommerce-android/pull/13386]
- [Internal] [*] Fixed a bug that could lead to a crash when formatting dates and times [https://github.com/woocommerce/woocommerce-android/pull/13393]
- [Internal] [*] Removed order creation survey from the order's list [https://github.com/woocommerce/woocommerce-android/pull/13423]
- [***] Updated the app look and feel to match the new WooCommerce branding [https://github.com/woocommerce/woocommerce-android/pull/13254]

21.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ object AppUrls {

const val CROWDSIGNAL_ANALYTICS_HUB_SURVEY = "https://automattic.survey.fm/woo-app-analytics-hub-production"

const val ORDER_CREATION_SURVEY = "https://automattic.survey.fm/woo-app-order-creation-production"

const val ADDONS_SURVEY = "https://automattic.survey.fm/woo-app-addons-production"

const val CROWDSIGNAL_STORE_SETUP_SURVEY =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ package com.woocommerce.android.analytics
import android.content.Context
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_DEVICE_TYPE_COMPACT
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_DEVICE_TYPE_REGULAR
import com.woocommerce.android.extensions.WindowSizeClass
import com.woocommerce.android.extensions.windowSizeClass
import com.woocommerce.android.extensions.isTwoPanesShouldBeUsed

val Context.deviceTypeToAnalyticsString: String
get() = buildAnalyticsDeviceTypeValue(
IsScreenLargerThanCompactValue(value = windowSizeClass != WindowSizeClass.Compact)
IsScreenInTwoPaneLayout(value = isTwoPanesShouldBeUsed)
)

val IsScreenLargerThanCompactValue.deviceTypeToAnalyticsString: String
val IsScreenInTwoPaneLayout.deviceTypeToAnalyticsString: String
get() = buildAnalyticsDeviceTypeValue(this)

private fun buildAnalyticsDeviceTypeValue(isScreenSizeLargerThanCompact: IsScreenLargerThanCompactValue) =
if (isScreenSizeLargerThanCompact.value) {
VALUE_DEVICE_TYPE_REGULAR
private fun buildAnalyticsDeviceTypeValue(isScreenInTwoPaneLayout: IsScreenInTwoPaneLayout) =
// Keeping the value as it is to maintain backward compatibility with the existing analytics data
if (isScreenInTwoPaneLayout.value) {
VALUE_DEVICE_TYPE_REGULAR // 2 pane layout
} else {
VALUE_DEVICE_TYPE_COMPACT
VALUE_DEVICE_TYPE_COMPACT // Single pane layout
}

@JvmInline
value class IsScreenLargerThanCompactValue(val value: Boolean)
value class IsScreenInTwoPaneLayout(val value: Boolean)
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,6 @@ class AnalyticsTracker private constructor(
const val VALUE_STATE_OFF = "off"

const val VALUE_SIMPLE_PAYMENTS_FLOW = "simple_payment"
const val VALUE_SIMPLE_PAYMENTS_FEEDBACK = "simple_payments"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_CARD = "card"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_CASH = "cash"
const val VALUE_SIMPLE_PAYMENTS_COLLECT_LINK = "payment_link"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,29 @@ import androidx.annotation.ColorRes
import androidx.core.content.ContextCompat
import com.woocommerce.android.util.SystemVersionUtils
import kotlinx.parcelize.Parcelize
import kotlin.math.max
import kotlin.math.min

val Context.windowSizeClass: WindowSizeClass
get() = determineWindowWidthSizeClassByGivenSize(resources.configuration.screenWidthDp)
val Context.isTwoPanesShouldBeUsed: Boolean
get() = determineIfTwoPanesShouldBeUsed(
resources.configuration.screenWidthDp,
resources.configuration.screenHeightDp
)

val Context.windowHeightSizeClass: WindowSizeClass
get() = determineWindowHeightSizeClassByGivenSize(resources.configuration.screenHeightDp)

private fun determineWindowWidthSizeClassByGivenSize(sizeDp: Int): WindowSizeClass {
return when {
sizeDp < WindowSizeClass.Compact.maxWidthDp -> WindowSizeClass.Compact
sizeDp < WindowSizeClass.Medium.maxWidthDp -> WindowSizeClass.Medium
else -> WindowSizeClass.ExpandedAndBigger
}
private const val MIN_SCREEN_SHORT_SIZE_DP = 674
private const val MIN_SCREEN_LONG_SIZE_DP = 800

private fun determineIfTwoPanesShouldBeUsed(widthDp: Int, heightDp: Int): Boolean {
val minScreenShortSizeDP = MIN_SCREEN_SHORT_SIZE_DP
val minScreenLongSizeDP = MIN_SCREEN_LONG_SIZE_DP

val shortSize = min(widthDp, heightDp)
val longSize = max(widthDp, heightDp)

return shortSize >= minScreenShortSizeDP && longSize >= minScreenLongSizeDP
}

private fun determineWindowHeightSizeClassByGivenSize(sizeDp: Int): WindowSizeClass {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,9 @@ data class FeatureFeedbackSettings(

enum class Feature {
PRODUCT_ADDONS,
SIMPLE_PAYMENTS_AND_ORDER_CREATION,
ANALYTICS_HUB,
ORDER_SHIPPING_LINES
}

fun isFeedbackMoreThanDaysAgo(days: Int) = Date(settingChangeDate).pastTimeDeltaFromNowInDays greaterThan days

fun isFeedbackGivenMoreThanDaysAgo(days: Int) =
feedbackState == FeedbackState.GIVEN &&
Date(settingChangeDate).pastTimeDeltaFromNowInDays greaterThan days
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_FEEDBA
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_FEEDBACK_STORE_SETUP_CONTEXT
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_ORDER_SHIPPING_LINES_FEEDBACK
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_PRODUCT_ADDONS_FEEDBACK
import com.woocommerce.android.analytics.AnalyticsTracker.Companion.VALUE_SIMPLE_PAYMENTS_FEEDBACK
import com.woocommerce.android.databinding.FragmentFeedbackSurveyBinding
import com.woocommerce.android.extensions.navigateSafely
import com.woocommerce.android.ui.base.BaseFragment
Expand All @@ -50,7 +49,6 @@ class FeedbackSurveyFragment : BaseFragment(R.layout.fragment_feedback_survey) {
SurveyType.MAIN -> VALUE_FEEDBACK_GENERAL_CONTEXT
SurveyType.PRODUCT -> VALUE_FEEDBACK_PRODUCT_M3_CONTEXT
SurveyType.STORE_ONBOARDING -> VALUE_FEEDBACK_STORE_SETUP_CONTEXT
SurveyType.ORDER_CREATION -> VALUE_SIMPLE_PAYMENTS_FEEDBACK
SurveyType.ADDONS -> VALUE_PRODUCT_ADDONS_FEEDBACK
SurveyType.ANALYTICS_HUB -> VALUE_ANALYTICS_HUB_FEEDBACK
SurveyType.ORDER_SHIPPING_LINES -> VALUE_ORDER_SHIPPING_LINES_FEEDBACK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.woocommerce.android.BuildConfig
@Suppress("MagicNumber")
enum class SurveyType(private val untaggedUrl: String, private val milestone: Int? = null) {
PRODUCT(AppUrls.CROWDSIGNAL_PRODUCT_SURVEY, 4),
ORDER_CREATION(AppUrls.ORDER_CREATION_SURVEY, 1),
MAIN(AppUrls.CROWDSIGNAL_MAIN_SURVEY),
ADDONS(AppUrls.ADDONS_SURVEY),
STORE_ONBOARDING(AppUrls.CROWDSIGNAL_STORE_SETUP_SURVEY),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ class MainActivity :

if (savedInstanceState == null) {
viewModel.handleIncomingAppLink(intent?.data)
viewModel.handleShortcutAction(intent?.action?.toLowerCase(Locale.ROOT))
viewModel.handleShortcutAction(intent?.action?.lowercase(Locale.ROOT))
handleIncomingImages()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,15 @@ import com.woocommerce.android.R
import com.woocommerce.android.databinding.FragmentOrderCreateEditFormBinding
import com.woocommerce.android.databinding.LayoutOrderCreationCustomerInfoBinding
import com.woocommerce.android.databinding.OrderCreationAdditionalInfoCollectionSectionBinding
import com.woocommerce.android.extensions.WindowSizeClass
import com.woocommerce.android.extensions.handleDialogNotice
import com.woocommerce.android.extensions.handleDialogResult
import com.woocommerce.android.extensions.handleResult
import com.woocommerce.android.extensions.hide
import com.woocommerce.android.extensions.isNotNullOrEmpty
import com.woocommerce.android.extensions.isTwoPanesShouldBeUsed
import com.woocommerce.android.extensions.navigateSafely
import com.woocommerce.android.extensions.show
import com.woocommerce.android.extensions.takeIfNotEqualTo
import com.woocommerce.android.extensions.windowSizeClass
import com.woocommerce.android.model.Address
import com.woocommerce.android.model.Order
import com.woocommerce.android.ui.barcodescanner.BarcodeScanningFragment
Expand Down Expand Up @@ -119,7 +118,6 @@ class OrderCreateEditFormFragment :
BackPressListener {
private companion object {
private const val TABLET_PANES_WIDTH_RATIO = 0.5F
private const val XL_TABLET_PANES_WIDTH_RATIO = 0.6F
}
private val viewModel by fixedHiltNavGraphViewModels<OrderCreateEditViewModel>(R.id.nav_graph_order_creations)
private val sharedViewModel: ProductSelectorSharedViewModel by activityViewModels()
Expand Down Expand Up @@ -171,8 +169,8 @@ class OrderCreateEditFormFragment :
viewModel.addCoupon(it)
}
handleTaxRateSelectionResult()
viewModel.onDeviceConfigurationChanged(requireContext().windowSizeClass)
if (requireContext().windowSizeClass != WindowSizeClass.Compact) syncSelectedItems()
viewModel.onDeviceConfigurationChanged(requireContext().isTwoPanesShouldBeUsed)
if (requireContext().isTwoPanesShouldBeUsed) syncSelectedItems()
}

private fun syncSelectedItems() {
Expand Down Expand Up @@ -229,13 +227,12 @@ class OrderCreateEditFormFragment :
}

private fun FragmentOrderCreateEditFormBinding.adjustUIForScreenSize() {
productSelectorNavContainer.isVisible = requireContext().windowSizeClass != WindowSizeClass.Compact
when (requireContext().windowSizeClass) {
WindowSizeClass.Compact -> twoPaneLayoutGuideline.setGuidelinePercent(0.0f)
WindowSizeClass.Medium -> twoPaneLayoutGuideline.setGuidelinePercent(TABLET_PANES_WIDTH_RATIO)
WindowSizeClass.ExpandedAndBigger -> twoPaneLayoutGuideline.setGuidelinePercent(XL_TABLET_PANES_WIDTH_RATIO)
productSelectorNavContainer.isVisible = requireContext().isTwoPanesShouldBeUsed
when (requireContext().isTwoPanesShouldBeUsed) {
false -> twoPaneLayoutGuideline.setGuidelinePercent(0.0f)
true -> twoPaneLayoutGuideline.setGuidelinePercent(TABLET_PANES_WIDTH_RATIO)
}
setupToolbars(requireContext().windowSizeClass != WindowSizeClass.Compact)
setupToolbars(requireContext().isTwoPanesShouldBeUsed)
}

private fun FragmentOrderCreateEditFormBinding.setupToolbars(isTablet: Boolean) {
Expand Down Expand Up @@ -605,7 +602,7 @@ class OrderCreateEditFormFragment :
binding.productsSection.hideAddProductsHeaderActions()
binding.productsSection.hideHeader()
binding.productsSection.content = null
if (requireContext().windowSizeClass == WindowSizeClass.Compact) {
if (!requireContext().isTwoPanesShouldBeUsed) {
binding.productsSection.setProductSectionButtons(
addProductsButton = AddButton(
text = getString(R.string.order_creation_add_products),
Expand All @@ -631,7 +628,7 @@ class OrderCreateEditFormFragment :
private fun productAddedCustomAmountUnset(binding: FragmentOrderCreateEditFormBinding) {
val isEditable = viewModel.viewStateData.liveData.value?.isEditable == true
if (isEditable) {
if (requireContext().windowSizeClass == WindowSizeClass.Compact) {
if (!requireContext().isTwoPanesShouldBeUsed) {
binding.productsSection.showAddProductsHeaderActions()
} else {
binding.productsSection.hideAddProductsHeaderActions()
Expand Down Expand Up @@ -662,7 +659,7 @@ class OrderCreateEditFormFragment :
binding.customAmountsSection.removeCustomSectionButtons()
binding.customAmountsSection.showHeader()
if (viewModel.viewStateData.liveData.value?.isEditable == true) {
if (requireContext().windowSizeClass == WindowSizeClass.Compact) {
if (!requireContext().isTwoPanesShouldBeUsed) {
binding.productsSection.showAddProductsHeaderActions()
} else {
binding.productsSection.hideAddProductsHeaderActions()
Expand All @@ -684,7 +681,7 @@ class OrderCreateEditFormFragment :
}

private fun FragmentOrderCreateEditFormBinding.renderDefaultProductsSectionButtons() {
if (requireContext().windowSizeClass == WindowSizeClass.Compact) {
if (!requireContext().isTwoPanesShouldBeUsed) {
productsSection.setProductSectionButtons(
addProductsButton = AddButton(
text = getString(R.string.order_creation_add_products),
Expand Down Expand Up @@ -1223,7 +1220,7 @@ class OrderCreateEditFormFragment :
}

is OnSelectedProductsSyncRequested -> {
if (requireContext().windowSizeClass != WindowSizeClass.Compact) {
if (requireContext().isTwoPanesShouldBeUsed) {
sharedViewModel.selectedItems.value.let { viewModel.onProductsSelected(it) }
}
}
Expand Down Expand Up @@ -1310,7 +1307,7 @@ class OrderCreateEditFormFragment :
isEachAddButtonEnabled = true
content.customAmountAdapter?.isLocked = false
}
if (requireContext().windowSizeClass != WindowSizeClass.Compact) {
if (requireContext().isTwoPanesShouldBeUsed) {
sharedViewModel.onProductSelectionStateChanged(true)
}
}
Expand Down Expand Up @@ -1340,7 +1337,7 @@ class OrderCreateEditFormFragment :
isEachAddButtonEnabled = false
content.customAmountAdapter?.isLocked = true
}
if (requireContext().windowSizeClass != WindowSizeClass.Compact) {
if (requireContext().isTwoPanesShouldBeUsed) {
sharedViewModel.onProductSelectionStateChanged(false)
}
}
Expand Down
Loading

0 comments on commit 5f8b670

Please sign in to comment.