Skip to content

Commit

Permalink
Merge branch 'refs/heads/trunk' into issue/12469-campaigns-objectives…
Browse files Browse the repository at this point in the history
…-endpoint

# Conflicts:
#	build.gradle
  • Loading branch information
JorgeMucientes committed Sep 20, 2024
2 parents 0cb3a39 + 692f475 commit e93a0bb
Show file tree
Hide file tree
Showing 57 changed files with 1,083 additions and 1,145 deletions.
18 changes: 18 additions & 0 deletions .buildkite/commands/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -u

echo "--- 🧹 Linting"
cp gradle.properties-example gradle.properties
./gradlew :WooCommerce:lintJalapenoDebug
app_lint_exit_code=$?

./gradlew :WooCommerce-Wear:lintJalapenoDebug
wear_lint_exit_code=$?

lint_exit_code=0
if [ $app_lint_exit_code -ne 0 ] || [ $wear_lint_exit_code -ne 0 ]; then
lint_exit_code=1
fi

upload_sarif_to_github 'WooCommerce/build/reports/lint-results-jalapenoDebug.sarif' 'woocommerce' 'woocommerce-android'

exit $lint_exit_code
5 changes: 1 addition & 4 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,7 @@ steps:
- "**/build/reports/detekt/detekt.html"

- label: "lint"
command: |
echo "--- 🧹 Linting"
cp gradle.properties-example gradle.properties
./gradlew lintJalapenoDebug
command: .buildkite/commands/lint.sh
plugins: [$CI_TOOLKIT]
artifact_paths:
- "**/build/reports/lint-results*.*"
Expand Down
4 changes: 4 additions & 0 deletions .buildkite/release-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ steps:
plugins: [$CI_TOOLKIT]
notify:
- slack: "#build-and-ship"
retry:
manual:
# If those jobs fail, one should always prefer re-triggering a new build from ReleaseV2 rather than retrying the individual job from Buildkite
allowed: false

- label: "🛠 Release Build (Wear App)"
command: |
Expand Down
9 changes: 5 additions & 4 deletions .buildkite/shared-pipeline-vars
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/bin/sh

# This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it.
# This file is `source`'d before calling `buildkite-agent pipeline upload`, and can be used
# to set up some variables that will be interpolated in the `.yml` pipeline before uploading it.

export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.6.2"
export TEST_COLLECTOR="test-collector#v1.10.1"

export CI_TOOLKIT="automattic/a8c-ci-toolkit#3.5.1"
export TEST_COLLECTOR="test-collector#v1.10.1"
5 changes: 4 additions & 1 deletion RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

20.5
-----

- [*] Fixes a bug that prevented users to rename the Product Variation Attributes to because of case insensitive checks [https://github.com/woocommerce/woocommerce-android/pull/12608]
- [*] Users can directly pick product images when creating Blaze ads [https://github.com/woocommerce/woocommerce-android/pull/12610]
- [*] Enables Blaze feature for sites with Blaze for WooCommerce plugin installed and active [https://github.com/woocommerce/woocommerce-android/pull/12640]
- [*] Fix for ConcurrentModificationException while removing notification [https://github.com/woocommerce/woocommerce-android/pull/12646]

20.4
-----
Expand Down
1 change: 1 addition & 0 deletions WooCommerce-Wear/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
android:name=".app.WearMainActivity"
android:exported="true"
android:taskAffinity=""
android:configChanges="density|fontScale|keyboard|keyboardHidden|layoutDirection|locale|mcc|mnc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|touchscreen|uiMode"
android:theme="@style/MainActivityTheme.Starting">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
2 changes: 1 addition & 1 deletion WooCommerce-Wear/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- Login Screen -->
<string name="login_screen_loading_text">Connecting</string>
<string name="login_screen_error_title">Log in</string>
<string name="login_screen_error_caption">Log in to Woo on your phone and hold your Watch nearby</string>
<string name="login_screen_error_caption">Log in to Woo on your phone and hold it nearby</string>
<string name="login_screen_action_button">It\'s not working</string>

<!-- Stats Screen -->
Expand Down
2 changes: 1 addition & 1 deletion WooCommerce-Wear/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<style name="MainActivityTheme.Starting" parent="Theme.SplashScreen">
<item name="windowSplashScreenBackground">@color/splash_background</item>
<item name="windowSplashScreenAnimatedIcon">@drawable/img_woo_bubble_white_animated</item>
<item name="windowSplashScreenAnimatedIcon">@mipmap/ic_launcher</item>
<item name="postSplashScreenTheme">@android:style/Theme.DeviceDefault</item>
</style>
</resources>
2 changes: 2 additions & 0 deletions WooCommerce/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,8 @@ android {
}

lintOptions {
sarifReport System.getenv('CI') ? true : false
checkDependencies true
disable 'InvalidPackage'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import com.woocommerce.android.e2e.screens.TabNavComponent
import com.woocommerce.android.model.Notification
import com.woocommerce.android.notifications.NotificationChannelType
import com.woocommerce.android.notifications.WooNotificationBuilder
import com.woocommerce.android.notifications.WooNotificationType.NEW_ORDER
import com.woocommerce.android.notifications.WooNotificationType.NewOrder

/**
* This is not a screen per-se, as it shows the notification drawer with a push notification.
Expand All @@ -32,7 +32,7 @@ class NotificationsScreen(private val wooNotificationBuilder: WooNotificationBui
icon = "https://s.wp.com/wp-content/mu-plugins/notes/images/update-payment-2x.png",
noteTitle = getTranslatedString(R.string.tests_notification_new_order_title),
noteMessage = getTranslatedString(R.string.tests_notification_new_order_message),
noteType = NEW_ORDER,
noteType = NewOrder,
channelType = NotificationChannelType.NEW_ORDER
),
isGroupNotification = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ import org.wordpress.android.mediapicker.api.MediaPickerSetup.DataSource.WP_MEDI
@Composable
fun MediaPickerDialog(
onDismissRequest: () -> Unit,
onMediaLibraryRequested: (DataSource) -> Unit
onMediaLibraryRequested: (DataSource) -> Unit,
withProductImagePicker: Boolean = false,
onProductImagesRequested: () -> Unit = {}
) {
Dialog(onDismissRequest = onDismissRequest) {
Card(
Expand Down Expand Up @@ -74,6 +76,13 @@ fun MediaPickerDialog(
title = string.image_source_wp_media_library,
onClick = { onMediaLibraryRequested(WP_MEDIA_LIBRARY) }
)
if (withProductImagePicker) {
DialogButton(
image = drawable.ic_product,
title = string.image_source_product_images,
onClick = onProductImagesRequested
)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,13 @@ data class Notification(
val data: String? = null
) : Parcelable {
@IgnoredOnParcel
val isOrderNotification = noteType == WooNotificationType.NEW_ORDER
val isOrderNotification = noteType is WooNotificationType.NewOrder

@IgnoredOnParcel
val isReviewNotification = noteType == WooNotificationType.PRODUCT_REVIEW
val isReviewNotification = noteType is WooNotificationType.ProductReview

@IgnoredOnParcel
val isBlazeNotification = noteType == WooNotificationType.BLAZE_APPROVED_NOTE ||
noteType == WooNotificationType.BLAZE_REJECTED_NOTE ||
noteType == WooNotificationType.BLAZE_CANCELLED_NOTE ||
noteType == WooNotificationType.BLAZE_PERFORMED_NOTE
val isBlazeNotification = noteType is WooNotificationType.BlazeStatusUpdate

/**
* Notifications are grouped based on the notification type and the store the notification belongs to.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,60 @@
package com.woocommerce.android.notifications

import android.os.Parcelable
import kotlinx.parcelize.IgnoredOnParcel
import kotlinx.parcelize.Parcelize
import org.wordpress.android.fluxc.model.notification.NotificationModel

enum class WooNotificationType {
NEW_ORDER,
PRODUCT_REVIEW,
LOCAL_REMINDER,
BLAZE_APPROVED_NOTE,
BLAZE_REJECTED_NOTE,
BLAZE_CANCELLED_NOTE,
BLAZE_PERFORMED_NOTE,
sealed interface WooNotificationType : Parcelable {
val trackingValue: String

@Parcelize
data object NewOrder : WooNotificationType {
@IgnoredOnParcel override val trackingValue: String = "NEW_ORDER"
}

@Parcelize
data object ProductReview : WooNotificationType {
@IgnoredOnParcel override val trackingValue: String = "PRODUCT_REVIEW"
}

@Parcelize
data object LocalReminder : WooNotificationType {
@IgnoredOnParcel override val trackingValue: String = "LOCAL_REMINDER"
}

@Parcelize
sealed interface BlazeStatusUpdate : WooNotificationType, Parcelable {
@Parcelize
data object BlazeApprovedNote : BlazeStatusUpdate {
@IgnoredOnParcel override val trackingValue: String = "blaze_approved_note"
}

@Parcelize
data object BlazeRejectedNote : BlazeStatusUpdate {
@IgnoredOnParcel override val trackingValue: String = "blaze_rejected_note"
}

@Parcelize
data object BlazeCancelledNote : BlazeStatusUpdate {
@IgnoredOnParcel override val trackingValue: String = "blaze_cancelled_note"
}

@Parcelize
data object BlazePerformedNote : BlazeStatusUpdate {
@IgnoredOnParcel override val trackingValue: String = "blaze_performed_note"
}
}
}

fun NotificationModel.getWooType(): WooNotificationType {
return when (this.type) {
NotificationModel.Kind.STORE_ORDER -> WooNotificationType.NEW_ORDER
NotificationModel.Kind.COMMENT -> WooNotificationType.PRODUCT_REVIEW
NotificationModel.Kind.BLAZE_APPROVED_NOTE -> WooNotificationType.BLAZE_APPROVED_NOTE
NotificationModel.Kind.BLAZE_REJECTED_NOTE -> WooNotificationType.BLAZE_REJECTED_NOTE
NotificationModel.Kind.BLAZE_CANCELLED_NOTE -> WooNotificationType.BLAZE_CANCELLED_NOTE
NotificationModel.Kind.BLAZE_PERFORMED_NOTE -> WooNotificationType.BLAZE_PERFORMED_NOTE
else -> WooNotificationType.LOCAL_REMINDER
NotificationModel.Kind.STORE_ORDER -> WooNotificationType.NewOrder
NotificationModel.Kind.COMMENT -> WooNotificationType.ProductReview
NotificationModel.Kind.BLAZE_APPROVED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeApprovedNote
NotificationModel.Kind.BLAZE_REJECTED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeRejectedNote
NotificationModel.Kind.BLAZE_CANCELLED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazeCancelledNote
NotificationModel.Kind.BLAZE_PERFORMED_NOTE -> WooNotificationType.BlazeStatusUpdate.BlazePerformedNote
else -> WooNotificationType.LocalReminder
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.woocommerce.android.analytics.AnalyticsTracker
import com.woocommerce.android.model.Notification
import com.woocommerce.android.notifications.NotificationChannelType.OTHER
import com.woocommerce.android.notifications.WooNotificationBuilder
import com.woocommerce.android.notifications.WooNotificationType.LOCAL_REMINDER
import com.woocommerce.android.notifications.WooNotificationType.LocalReminder
import com.woocommerce.android.notifications.local.LocalNotificationScheduler.Companion.LOCAL_NOTIFICATION_DATA
import com.woocommerce.android.notifications.local.LocalNotificationScheduler.Companion.LOCAL_NOTIFICATION_DESC
import com.woocommerce.android.notifications.local.LocalNotificationScheduler.Companion.LOCAL_NOTIFICATION_ID
Expand Down Expand Up @@ -103,7 +103,7 @@ class LocalNotificationWorker @AssistedInject constructor(
icon = null,
noteTitle = title,
noteMessage = description,
noteType = LOCAL_REMINDER,
noteType = LocalReminder,
channelType = OTHER,
data = data
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class NotificationAnalyticsTracker @Inject constructor(
val isFromSelectedSite = selectedSite.getIfExists()?.siteId == notification.remoteSiteId
val properties = mutableMapOf<String, Any>()
properties["notification_note_id"] = notification.remoteNoteId
properties["notification_type"] = notification.noteType.name
properties["notification_type"] = notification.noteType.trackingValue
properties["push_notification_token"] = appPrefsWrapper.getFCMToken()
properties["is_from_selected_site"] = isFromSelectedSite == true
analyticsTrackerWrapper.track(stat, properties)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import com.woocommerce.android.model.isOrderNotification
import com.woocommerce.android.model.toAppModel
import com.woocommerce.android.notifications.NotificationChannelType
import com.woocommerce.android.notifications.WooNotificationBuilder
import com.woocommerce.android.notifications.WooNotificationType.NEW_ORDER
import com.woocommerce.android.notifications.WooNotificationType.NewOrder
import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.util.NotificationsParser
import com.woocommerce.android.util.WooLog.T.NOTIFS
Expand Down Expand Up @@ -52,10 +52,12 @@ class NotificationMessageHandler @Inject constructor(
private val ACTIVE_NOTIFICATIONS_MAP = mutableMapOf<Int, Notification>()
}

@Synchronized
fun onPushNotificationDismissed(notificationId: Int) {
removeNotificationByNotificationIdFromSystemsBar(notificationId)
}

@Synchronized
fun onLocalNotificationDismissed(notificationId: Int, notificationType: String) {
removeNotificationByNotificationIdFromSystemsBar(notificationId)
AnalyticsTracker.track(
Expand Down Expand Up @@ -128,7 +130,7 @@ class NotificationMessageHandler @Inject constructor(
}

private fun handleWooNotification(notification: Notification) {
val randomNumber = if (notification.noteType == NEW_ORDER) Random.nextInt() else 0
val randomNumber = if (notification.noteType == NewOrder) Random.nextInt() else 0
val localPushId = getLocalPushIdForNoteId(notification.remoteNoteId, randomNumber)
ACTIVE_NOTIFICATIONS_MAP[getLocalPushId(localPushId, randomNumber)] = notification
if (notificationBuilder.isNotificationsEnabled()) {
Expand Down Expand Up @@ -221,6 +223,7 @@ class NotificationMessageHandler @Inject constructor(
notificationBuilder.cancelAllNotifications()
}

@Synchronized
fun removeNotificationByRemoteIdFromSystemsBar(remoteNoteId: Long) {
val keptNotifs = HashMap<Int, Notification>()
ACTIVE_NOTIFICATIONS_MAP.asSequence()
Expand All @@ -237,6 +240,7 @@ class NotificationMessageHandler @Inject constructor(
updateNotificationsState()
}

@Synchronized
fun removeNotificationByNotificationIdFromSystemsBar(localPushId: Int) {
val keptNotifs = HashMap<Int, Notification>()
ACTIVE_NOTIFICATIONS_MAP.asSequence()
Expand All @@ -253,6 +257,7 @@ class NotificationMessageHandler @Inject constructor(
updateNotificationsState()
}

@Synchronized
fun removeNotificationsOfTypeFromSystemsBar(type: NotificationChannelType, remoteSiteId: Long) {
val keptNotifs = HashMap<Int, Notification>()
// Using a copy of the map to avoid concurrency problems
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,32 @@
package com.woocommerce.android.ui.blaze

import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.tools.SiteConnectionType
import com.woocommerce.android.tools.SiteConnectionType.Jetpack
import com.woocommerce.android.util.IsRemoteFeatureFlagEnabled
import com.woocommerce.android.util.RemoteFeatureFlag.WOO_BLAZE
import javax.inject.Inject

class IsBlazeEnabled @Inject constructor(
private val selectedSite: SelectedSite,
private val isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled,
private val isRemoteFeatureFlagEnabled: IsRemoteFeatureFlagEnabled
) {
companion object {
private const val BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG = "blaze-ads"
}

suspend operator fun invoke(): Boolean = selectedSite.getIfExists()?.isAdmin ?: false &&
selectedSite.connectionType == SiteConnectionType.Jetpack &&
hasAValidJetpackConnectionForBlaze() &&
selectedSite.getIfExists()?.canBlaze ?: false &&
isRemoteFeatureFlagEnabled(WOO_BLAZE)

/**
* In order for Blaze to work, the site requires the Jetpack Sync module to be enabled. This means not all
* Jetpack connection will work. For now, Blaze will only be enabled for sites with Jetpack plugin installed and
* active, or for sites with Blaze for WooCommerce plugin installed and connected.
*/
private fun hasAValidJetpackConnectionForBlaze() =
selectedSite.connectionType == Jetpack || isBlazeForWooCommercePluginActive()

private fun isBlazeForWooCommercePluginActive(): Boolean =
selectedSite.get().activeJetpackConnectionPlugins?.contains(BLAZE_FOR_WOOCOMMERCE_PLUGIN_SLUG) == true
}
Loading

0 comments on commit e93a0bb

Please sign in to comment.