Skip to content

Commit

Permalink
rename fixes kotlin
Browse files Browse the repository at this point in the history
  • Loading branch information
mrehan27 committed Sep 28, 2023
1 parent 3159c93 commit 0abe841
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class MainApplication : Application() {
addCustomerIOModule(
ModuleMessagingPushFCM(
config = with(MessagingPushModuleConfig.Builder()) {
setNotificationClickBehavior(configuration.notificationClickBehavior)
setPushClickBehavior(configuration.pushClickBehavior)
}.build()
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.customer.android.sample.kotlin_compose.data.models

import io.customer.messagingpush.config.NotificationClickBehavior
import io.customer.messagingpush.config.PushClickBehavior
import io.customer.sdk.CustomerIO
import io.customer.sdk.CustomerIOConfig.Companion.AnalyticsConstants.AUTO_TRACK_DEVICE_ATTRIBUTES
import io.customer.sdk.CustomerIOConfig.Companion.AnalyticsConstants.BACKGROUND_QUEUE_MIN_NUMBER_OF_TASKS
Expand All @@ -14,7 +14,7 @@ data class Configuration(
var trackUrl: String? = null,
var backgroundQueueSecondsDelay: Double = BACKGROUND_QUEUE_SECONDS_DELAY,
var backgroundQueueMinNumTasks: Int = BACKGROUND_QUEUE_MIN_NUMBER_OF_TASKS,
var notificationClickBehavior: NotificationClickBehavior = NotificationClickBehavior.ACTIVITY_PREVENT_RESTART,
var pushClickBehavior: PushClickBehavior = PushClickBehavior.ACTIVITY_PREVENT_RESTART,
var trackScreen: Boolean = SHOULD_AUTO_RECORD_SCREEN_VIEWS,
var trackDeviceAttributes: Boolean = AUTO_TRACK_DEVICE_ATTRIBUTES,
var debugMode: Boolean = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.API_KEY
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.BACKGROUND_QUEUE_MIN_NUM_TASKS
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.BACKGROUND_QUEUE_SECONDS_DELAY
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.DEBUG_MODE
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.NOTIFICATION_CLICK_BEHAVIOR_KEY
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.PUSH_CLICK_BEHAVIOR_KEY
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.SITE_ID
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.TRACK_API_URL_KEY
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.TRACK_DEVICE_ATTRIBUTES
import io.customer.android.sample.kotlin_compose.util.PreferencesKeys.TRACK_SCREEN
import io.customer.messagingpush.config.NotificationClickBehavior
import io.customer.messagingpush.config.PushClickBehavior
import io.customer.sdk.CustomerIOConfig
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
Expand All @@ -35,8 +35,8 @@ class PreferenceRepositoryImp(private val dataStore: DataStore<Preferences>) :
configuration.trackUrl?.let { preferences[TRACK_API_URL_KEY] = it }
preferences[BACKGROUND_QUEUE_SECONDS_DELAY] = configuration.backgroundQueueSecondsDelay
preferences[BACKGROUND_QUEUE_MIN_NUM_TASKS] = configuration.backgroundQueueMinNumTasks
preferences[NOTIFICATION_CLICK_BEHAVIOR_KEY] =
configuration.notificationClickBehavior.name
preferences[PUSH_CLICK_BEHAVIOR_KEY] =
configuration.pushClickBehavior.name
preferences[TRACK_SCREEN] = configuration.trackScreen
preferences[TRACK_DEVICE_ATTRIBUTES] = configuration.trackDeviceAttributes
preferences[DEBUG_MODE] = configuration.debugMode
Expand All @@ -59,14 +59,14 @@ class PreferenceRepositoryImp(private val dataStore: DataStore<Preferences>) :
backgroundQueueMinNumTasks = preferences[BACKGROUND_QUEUE_MIN_NUM_TASKS]
?: CustomerIOConfig.Companion.AnalyticsConstants.BACKGROUND_QUEUE_MIN_NUMBER_OF_TASKS

notificationClickBehavior =
preferences[NOTIFICATION_CLICK_BEHAVIOR_KEY]?.takeIf { name ->
pushClickBehavior =
preferences[PUSH_CLICK_BEHAVIOR_KEY]?.takeIf { name ->
name.isNotBlank()
}?.let { name ->
kotlin.runCatching {
enumValueOf<NotificationClickBehavior>(name)
enumValueOf<PushClickBehavior>(name)
}.getOrNull()
} ?: NotificationClickBehavior.ACTIVITY_PREVENT_RESTART
} ?: PushClickBehavior.ACTIVITY_PREVENT_RESTART

trackScreen = preferences[TRACK_SCREEN] ?: true

Expand All @@ -87,7 +87,7 @@ class PreferenceRepositoryImp(private val dataStore: DataStore<Preferences>) :
CustomerIOConfig.Companion.AnalyticsConstants.BACKGROUND_QUEUE_SECONDS_DELAY
backgroundQueueMinNumTasks =
CustomerIOConfig.Companion.AnalyticsConstants.BACKGROUND_QUEUE_MIN_NUMBER_OF_TASKS
notificationClickBehavior = NotificationClickBehavior.ACTIVITY_PREVENT_RESTART
pushClickBehavior = PushClickBehavior.ACTIVITY_PREVENT_RESTART
trackScreen = true
trackDeviceAttributes = true
debugMode = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import io.customer.android.sample.kotlin_compose.R
import io.customer.android.sample.kotlin_compose.data.models.Configuration
import io.customer.android.sample.kotlin_compose.ui.components.TrackScreenLifecycle
import io.customer.messagingpush.config.NotificationClickBehavior
import io.customer.messagingpush.config.PushClickBehavior
import io.customer.sdk.CustomerIO

@Composable
Expand Down Expand Up @@ -353,7 +353,7 @@ fun SDKSettingsList(
OutlinedTextField(
modifier = Modifier.fillMaxWidth(),
readOnly = true,
value = configuration.notificationClickBehavior.name,
value = configuration.pushClickBehavior.name,
onValueChange = {},
label = { Text(text = "Notification Click Behavior") },
trailingIcon = {
Expand All @@ -368,14 +368,14 @@ fun SDKSettingsList(
modifier = Modifier.fillMaxWidth(),
onDismissRequest = { pushBehaviorDropdownExpanded = true }
) {
NotificationClickBehavior.values().forEach { value ->
PushClickBehavior.values().forEach { value ->
DropdownMenuItem(
modifier = Modifier.padding(8.dp),
onClick = {
pushBehaviorDropdownExpanded = !pushBehaviorDropdownExpanded
onConfigurationChange(
configuration.copy(
notificationClickBehavior = value
pushClickBehavior = value
)
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ object PreferencesKeys {
val BACKGROUND_QUEUE_SECONDS_DELAY = doublePreferencesKey("backgroundQueueSecondsDelay")
val BACKGROUND_QUEUE_MIN_NUM_TASKS = intPreferencesKey("backgroundQueueMinNumTasks")

val NOTIFICATION_CLICK_BEHAVIOR_KEY = stringPreferencesKey("notificationClickBehaviorKey")
val PUSH_CLICK_BEHAVIOR_KEY = stringPreferencesKey("pushClickBehaviorKey")

val TRACK_SCREEN = booleanPreferencesKey("trackScreen")
val TRACK_DEVICE_ATTRIBUTES = booleanPreferencesKey("trackDeviceAttributes")
Expand Down

0 comments on commit 0abe841

Please sign in to comment.