diff --git a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java index f53da4f0..3a4df871 100644 --- a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java +++ b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/data/model/CustomerIOSDKConfig.java @@ -11,6 +11,7 @@ import io.customer.android.sample.java_layout.BuildConfig; import io.customer.android.sample.java_layout.support.Optional; import io.customer.android.sample.java_layout.utils.StringUtils; +import io.customer.datapipelines.config.ScreenView; import io.customer.datapipelines.extensions.RegionExtKt; import io.customer.sdk.core.util.CioLogLevel; import io.customer.sdk.data.model.Region; @@ -28,6 +29,7 @@ private static class Keys { static final String TRACK_DEVICE_ATTRIBUTES = "cio_sdk_track_device_attributes"; static final String LOG_LEVEL = "cio_sdk_log_level"; static final String REGION = "cio_sdk_region"; + static final String SCREEN_VIEW_USE = "cio_sdk_screen_view_use"; static final String TRACK_APPLICATION_LIFECYCLE = "cio_sdk_track_application_lifecycle"; static final String TEST_MODE_ENABLED = "cio_sdk_test_mode"; static final String IN_APP_MESSAGING_ENABLED = "cio_sdk_in_app_messaging_enabled"; @@ -42,6 +44,7 @@ public static CustomerIOSDKConfig getDefaultConfigurations() { true, CioLogLevel.DEBUG, Region.US.INSTANCE, + ScreenView.Analytics, true, false, true); @@ -62,6 +65,7 @@ public static Optional fromMap(@NonNull Map boolean deviceAttributesTrackingEnabled = StringUtils.parseBoolean(bundle.get(Keys.TRACK_DEVICE_ATTRIBUTES), defaultConfig.deviceAttributesTrackingEnabled); CioLogLevel logLevel = CioLogLevel.Companion.getLogLevel(bundle.get(Keys.LOG_LEVEL), CioLogLevel.DEBUG); Region region = Region.Companion.getRegion(bundle.get(Keys.REGION), Region.US.INSTANCE); + ScreenView screenViewUse = ScreenView.Companion.getScreenView(bundle.get(Keys.SCREEN_VIEW_USE)); boolean applicationLifecycleTrackingEnabled = StringUtils.parseBoolean(bundle.get(Keys.TRACK_APPLICATION_LIFECYCLE), defaultConfig.applicationLifecycleTrackingEnabled); boolean testModeEnabled = StringUtils.parseBoolean(bundle.get(Keys.TEST_MODE_ENABLED), defaultConfig.testModeEnabled); boolean inAppMessagingEnabled = StringUtils.parseBoolean(bundle.get(Keys.IN_APP_MESSAGING_ENABLED), defaultConfig.inAppMessagingEnabled); @@ -74,6 +78,7 @@ public static Optional fromMap(@NonNull Map deviceAttributesTrackingEnabled, logLevel, region, + screenViewUse, applicationLifecycleTrackingEnabled, testModeEnabled, inAppMessagingEnabled); @@ -91,6 +96,7 @@ public static Map toMap(@NonNull CustomerIOSDKConfig config) { bundle.put(Keys.TRACK_DEVICE_ATTRIBUTES, StringUtils.fromBoolean(config.deviceAttributesTrackingEnabled)); bundle.put(Keys.LOG_LEVEL, config.logLevel.name()); bundle.put(Keys.REGION, config.getRegion().getCode()); + bundle.put(Keys.SCREEN_VIEW_USE, config.getScreenViewUse().name()); bundle.put(Keys.TRACK_APPLICATION_LIFECYCLE, StringUtils.fromBoolean(config.applicationLifecycleTrackingEnabled)); bundle.put(Keys.TEST_MODE_ENABLED, StringUtils.fromBoolean(config.testModeEnabled)); bundle.put(Keys.IN_APP_MESSAGING_ENABLED, StringUtils.fromBoolean(config.inAppMessagingEnabled)); @@ -111,6 +117,7 @@ public static Map toMap(@NonNull CustomerIOSDKConfig config) { private final CioLogLevel logLevel; @NonNull private final Region region; + private final ScreenView screenViewUse; private final boolean applicationLifecycleTrackingEnabled; private final boolean testModeEnabled; private final boolean inAppMessagingEnabled; @@ -123,6 +130,7 @@ public CustomerIOSDKConfig(@NonNull String cdpApiKey, boolean deviceAttributesTrackingEnabled, @NonNull CioLogLevel logLevel, @NonNull Region region, + @NonNull ScreenView screenViewUse, boolean applicationLifecycleTrackingEnabled, boolean testModeEnabled, boolean inAppMessagingEnabled) { @@ -134,6 +142,7 @@ public CustomerIOSDKConfig(@NonNull String cdpApiKey, this.deviceAttributesTrackingEnabled = deviceAttributesTrackingEnabled; this.logLevel = logLevel; this.region = region; + this.screenViewUse = screenViewUse; this.applicationLifecycleTrackingEnabled = applicationLifecycleTrackingEnabled; this.testModeEnabled = testModeEnabled; this.inAppMessagingEnabled = inAppMessagingEnabled; @@ -188,4 +197,9 @@ public boolean isApplicationLifecycleTrackingEnabled() { public Region getRegion() { return region; } + + @NonNull + public ScreenView getScreenViewUse() { + return screenViewUse; + } } diff --git a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/InternalSettingsActivity.java b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/InternalSettingsActivity.java index f53260ff..7cd5c519 100644 --- a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/InternalSettingsActivity.java +++ b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/InternalSettingsActivity.java @@ -137,6 +137,7 @@ private static CustomerIOSDKConfig createNewSettings(CustomerIOSDKConfig current currentSettings.isDeviceAttributesTrackingEnabled(), currentSettings.getLogLevel(), currentSettings.getRegion(), + currentSettings.getScreenViewUse(), currentSettings.isApplicationLifecycleTrackingEnabled(), currentSettings.isTestModeEnabled(), currentSettings.isInAppMessagingEnabled() diff --git a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/SettingsActivity.java b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/SettingsActivity.java index aa237c58..ce11ec4f 100644 --- a/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/SettingsActivity.java +++ b/samples/java_layout/src/main/java/io/customer/android/sample/java_layout/ui/settings/SettingsActivity.java @@ -17,6 +17,7 @@ import io.customer.android.sample.java_layout.ui.dashboard.DashboardActivity; import io.customer.android.sample.java_layout.utils.OSUtils; import io.customer.android.sample.java_layout.utils.ViewUtils; +import io.customer.datapipelines.config.ScreenView; import io.customer.sdk.core.util.CioLogLevel; import io.customer.sdk.data.model.Region; import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers; @@ -128,6 +129,7 @@ private void updateIOWithConfig(@NonNull CustomerIOSDKConfig config) { binding.settingsTrackDeviceAttrsValuesGroup.check(getCheckedAutoTrackDeviceAttributesButtonId(config.isDeviceAttributesTrackingEnabled())); binding.settingsTrackScreenViewsValuesGroup.check(getCheckedTrackScreenViewsButtonId(config.isScreenTrackingEnabled())); binding.settingsTrackAppLifecycleValuesGroup.check(getCheckedTrackAppLifecycleButtonId(config.isApplicationLifecycleTrackingEnabled())); + binding.screenViewUseSettingsValuesGroup.check(getCheckedScreenViewUseButtonId(config.getScreenViewUse())); binding.settingsLogLevelValuesGroup.check(getCheckedLogLevelButtonId(config.getLogLevel())); binding.settingsTestModeValuesGroup.check(getCheckedTestModeButtonId(config.isTestModeEnabled())); binding.settingsInAppMessagingValuesGroup.check(getCheckedInAppMessagingButtonId(config.isInAppMessagingEnabled())); @@ -173,6 +175,7 @@ private CustomerIOSDKConfig createNewSettings(String cdpApiKey, String siteId, C boolean featInAppMessagingEnabled = binding.settingsInAppMessagingValuesGroup.getCheckedButtonId() == R.id.settings_in_app_messaging_yes_button; CioLogLevel logLevel = getSelectedLogLevel(); Region region = getSelectedRegion(); + ScreenView screenViewUse = getSelectedScreenViewUse(); return new CustomerIOSDKConfig(cdpApiKey, siteId, @@ -182,6 +185,7 @@ private CustomerIOSDKConfig createNewSettings(String cdpApiKey, String siteId, C featTrackDeviceAttributes, logLevel, region, + screenViewUse, featTrackApplicationLifecycle, featTestModeEnabled, featInAppMessagingEnabled); @@ -213,6 +217,18 @@ private Region getSelectedRegion() { throw new IllegalStateException(); } + + @NonNull + private ScreenView getSelectedScreenViewUse() { + int checkedButton = binding.screenViewUseSettingsValuesGroup.getCheckedButtonId(); + if (checkedButton == R.id.settings_screen_view_use_analytics_button) { + return ScreenView.Analytics; + } else if (checkedButton == R.id.settings_screen_view_use_in_app_button) { + return ScreenView.InApp; + } + throw new IllegalStateException(); + } + private int getCheckedInAppMessagingButtonId(boolean enabled) { return enabled ? R.id.settings_in_app_messaging_yes_button : R.id.settings_in_app_messaging_no_button; } @@ -256,6 +272,16 @@ private int getCheckedRegionButtonId(@NonNull Region region) { : R.id.settings_region_eu_button; } + private int getCheckedScreenViewUseButtonId(@NonNull ScreenView screenViewUse) { + switch (screenViewUse) { + case InApp: + return R.id.settings_screen_view_use_in_app_button; + case Analytics: + default: + return R.id.settings_screen_view_use_analytics_button; + } + } + private boolean updateErrorState(TextInputLayout textInputLayout, boolean isErrorEnabled, @StringRes int errorResId) { diff --git a/samples/java_layout/src/main/res/layout/activity_settings.xml b/samples/java_layout/src/main/res/layout/activity_settings.xml index f448e50d..982d18eb 100644 --- a/samples/java_layout/src/main/res/layout/activity_settings.xml +++ b/samples/java_layout/src/main/res/layout/activity_settings.xml @@ -234,6 +234,46 @@ android:text="@string/settings_no" /> + + + + +