Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 8 additions & 8 deletions WooCommerce/src/main/kotlin/com/woocommerce/android/AppPrefs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,14 @@ object AppPrefs {
get() = getBoolean(DeletablePrefKey.JETPACK_APP_PASSWORDS_ENABLED, true)
set(value) = setBoolean(DeletablePrefKey.JETPACK_APP_PASSWORDS_ENABLED, value)

var isWooPosSurveyNotificationCurrentUserShown: Boolean
get() = getBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_CURRENT_USER_SHOWN, false)
set(value) = setBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_CURRENT_USER_SHOWN, value)

var isWooPosSurveyNotificationPotentialUserShown: Boolean
get() = getBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_POTENTIAL_USER_SHOWN, false)
set(value) = setBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_POTENTIAL_USER_SHOWN, value)

fun getProductSortingChoice(currentSiteId: Int) = getString(getProductSortingKey(currentSiteId)).orNullIfEmpty()

fun setProductSortingChoice(currentSiteId: Int, value: String) {
Expand Down Expand Up @@ -1357,14 +1365,6 @@ object AppPrefs {
)
}

var isWooPosSurveyNotificationCurrentUserShown: Boolean
get() = getBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_CURRENT_USER_SHOWN, false)
set(value) = setBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_CURRENT_USER_SHOWN, value)

var isWooPosSurveyNotificationPotentialUserShown: Boolean
get() = getBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_POTENTIAL_USER_SHOWN, false)
set(value) = setBoolean(UndeletablePrefKey.WOO_POS_SURVEY_NOTIFICATION_POTENTIAL_USER_SHOWN, value)

enum class CardReaderOnboardingStatus {
CARD_READER_ONBOARDING_COMPLETED,
CARD_READER_ONBOARDING_PENDING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ open class AppPrefsWrapper @Inject constructor() {

var isSiteWPComSuspended by AppPrefs::isSiteWPComSuspended

var isWooPosSurveyNotificationPotentialUserShown by AppPrefs::isWooPosSurveyNotificationPotentialUserShown

var isWooPosSurveyNotificationCurrentUserShown by AppPrefs::isWooPosSurveyNotificationCurrentUserShown

open var orderSummaryMigrated by AppPrefs::orderSummaryMigrated
open var gatewayMigrated by AppPrefs::gatewayMigrated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,28 @@ sealed class LocalNotification(
delay = 1,
delayUnit = TimeUnit.DAYS
)

data class WooPosSurveyPotentialUserNotification(
override val siteId: Long,
override val delay: Long = 0,
) : LocalNotification(
siteId = siteId,
title = R.string.local_notification_woo_pos_survey_potential_user_title,
description = R.string.local_notification_woo_pos_survey_potential_user_description,
type = LocalNotificationType.WOO_POS_SURVEY_POTENTIAL_USER_REMINDER,
delay = delay,
delayUnit = TimeUnit.MILLISECONDS
)

data class WooPosSurveyCurrentUserNotification(
override val siteId: Long,
override val delay: Long = 0,
) : LocalNotification(
siteId = siteId,
title = R.string.local_notification_woo_pos_survey_current_user_title,
description = R.string.local_notification_woo_pos_survey_current_user_description,
type = LocalNotificationType.WOO_POS_SURVEY_CURRENT_USER_REMINDER,
delay = delay,
delayUnit = TimeUnit.MILLISECONDS
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package com.woocommerce.android.notifications.local

enum class LocalNotificationType(val value: String) {
BLAZE_NO_CAMPAIGN_REMINDER("blaze_no_campaign_reminder"),
BLAZE_ABANDONED_CAMPAIGN_REMINDER("blaze_abandoned_campaign_reminder");
BLAZE_ABANDONED_CAMPAIGN_REMINDER("blaze_abandoned_campaign_reminder"),
WOO_POS_SURVEY_POTENTIAL_USER_REMINDER("woo_pos_survey_potential_user_reminder"),
WOO_POS_SURVEY_CURRENT_USER_REMINDER("woo_pos_survey_current_user_reminder");
override fun toString() = value

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ class LocalNotificationWorker @AssistedInject constructor(
appsPrefsWrapper.isBlazeAbandonedCampaignReminderShown = true
}

LocalNotificationType.WOO_POS_SURVEY_POTENTIAL_USER_REMINDER -> {
appsPrefsWrapper.isWooPosSurveyNotificationPotentialUserShown = true
}

LocalNotificationType.WOO_POS_SURVEY_CURRENT_USER_REMINDER -> {
appsPrefsWrapper.isWooPosSurveyNotificationCurrentUserShown = true
}

else -> {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class PreconditionCheckWorker @AssistedInject constructor(
LocalNotificationType.BLAZE_NO_CAMPAIGN_REMINDER,
LocalNotificationType.BLAZE_ABANDONED_CAMPAIGN_REMINDER -> proceedIfValidSiteAndBlazeAvailable(siteId)

LocalNotificationType.WOO_POS_SURVEY_POTENTIAL_USER_REMINDER,
LocalNotificationType.WOO_POS_SURVEY_CURRENT_USER_REMINDER -> proceedIfValidSite(siteId)

null -> cancelWork("Notification type is null. Cancelling work.")
}
}
Expand All @@ -63,6 +66,23 @@ class PreconditionCheckWorker @AssistedInject constructor(
else -> Result.success()
}

private fun proceedIfValidSite(siteId: Long) = when {
siteId == 0L -> {
val message = "Site id is missing. Cancelling local notification work."
crashLogging.sendReport(
exception = Exception(message),
message = "PreconditionCheckWorker: cancelling work"
)
cancelWork(message)
}

siteStore.getSiteBySiteId(siteId) == null -> {
cancelWork("The site linked to the notifications doesn't exist in the db. Cancelling work.")
}

else -> Result.success()
}

private val canDisplayNotifications: Boolean
get() = VERSION.SDK_INT < VERSION_CODES.TIRAMISU || WooPermissionUtils.hasNotificationsPermission(appContext)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import com.woocommerce.android.notifications.WooNotificationType
import com.woocommerce.android.notifications.local.LocalNotificationType
import com.woocommerce.android.notifications.local.LocalNotificationType.BLAZE_ABANDONED_CAMPAIGN_REMINDER
import com.woocommerce.android.notifications.local.LocalNotificationType.BLAZE_NO_CAMPAIGN_REMINDER
import com.woocommerce.android.notifications.local.LocalNotificationType.WOO_POS_SURVEY_CURRENT_USER_REMINDER
import com.woocommerce.android.notifications.local.LocalNotificationType.WOO_POS_SURVEY_POTENTIAL_USER_REMINDER
import com.woocommerce.android.notifications.push.NotificationMessageHandler
import com.woocommerce.android.tools.SelectedSite
import com.woocommerce.android.tools.SiteConnectionType.Jetpack
Expand Down Expand Up @@ -286,6 +288,9 @@ class MainActivityViewModel @Inject constructor(
when (it) {
BLAZE_NO_CAMPAIGN_REMINDER,
BLAZE_ABANDONED_CAMPAIGN_REMINDER -> triggerEvent(LaunchBlazeCampaignCreation)

WOO_POS_SURVEY_POTENTIAL_USER_REMINDER,
WOO_POS_SURVEY_CURRENT_USER_REMINDER -> error("POS Survey notifications are not implemented yet")
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions WooCommerce/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3210,6 +3210,10 @@
<string name="local_notification_blaze_no_campaign_reminder_description">Promote your products with Blaze Ads and increase your sales now.</string>
<string name="local_notification_blaze_abandoned_campaign_reminder_title">Thinking about boosting your sales?</string>
<string name="local_notification_blaze_abandoned_campaign_reminder_description">Get your products seen by millions with Blaze and boost your sales</string>
<string name="local_notification_woo_pos_survey_potential_user_title">Thinking about in-person sales?</string>
<string name="local_notification_woo_pos_survey_potential_user_description">Help us build tools you\'d actually use. 2-minute survey to build tools you\'ll love.</string>
<string name="local_notification_woo_pos_survey_current_user_title">How\'s POS working for you?</string>
<string name="local_notification_woo_pos_survey_current_user_description">Share your experience in 2 minutes and help us improve.</string>

<!--
First product published congratulatory feature
Expand Down