From 1fc7be2e52b9878971d2fedb5cb08161ea6a2abd Mon Sep 17 00:00:00 2001 From: Farhan Arshad Date: Mon, 8 Jul 2024 21:08:33 +0500 Subject: [PATCH] fix: code improvements --- .../openedx/core/data/model/CourseStructureModel.kt | 2 +- .../org/openedx/core/data/model/EnrolledCourse.kt | 2 +- .../openedx/core/domain/interactor/IAPInteractor.kt | 2 +- .../org/openedx/core/domain/model/CourseStructure.kt | 2 +- .../org/openedx/core/domain/model/EnrolledCourse.kt | 2 +- .../core/domain/{ => model/iap}/ProductInfo.kt | 2 +- .../core/domain/model/iap/PurchaseFlowData.kt | 1 - .../openedx/core/module/billing/BillingProcessor.kt | 2 +- .../core/presentation/dialog/IAPDialogFragment.kt | 2 +- .../org/openedx/core/presentation/iap/IAPUIState.kt | 2 +- .../openedx/core/presentation/iap/IAPViewModel.kt | 3 ++- core/src/main/res/values/strings.xml | 1 + .../dashboard/presentation/DashboardListFragment.kt | 2 +- .../dashboard/presentation/DashboardListViewModel.kt | 11 ++++++----- .../presentation/settings/SettingsFragment.kt | 2 +- .../presentation/settings/SettingsViewModel.kt | 12 +++++++----- 16 files changed, 27 insertions(+), 23 deletions(-) rename core/src/main/java/org/openedx/core/domain/{ => model/iap}/ProductInfo.kt (80%) diff --git a/core/src/main/java/org/openedx/core/data/model/CourseStructureModel.kt b/core/src/main/java/org/openedx/core/data/model/CourseStructureModel.kt index 675672c2b..7afea74a0 100644 --- a/core/src/main/java/org/openedx/core/data/model/CourseStructureModel.kt +++ b/core/src/main/java/org/openedx/core/data/model/CourseStructureModel.kt @@ -11,9 +11,9 @@ import org.openedx.core.data.model.room.CourseStructureEntity import org.openedx.core.data.model.room.MediaDb import org.openedx.core.data.model.room.discovery.ProgressDb import org.openedx.core.data.storage.CorePreferences -import org.openedx.core.domain.ProductInfo import org.openedx.core.domain.model.CourseStructure import org.openedx.core.domain.model.EnrollmentMode +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.utils.TimeUtils import java.lang.reflect.Type diff --git a/core/src/main/java/org/openedx/core/data/model/EnrolledCourse.kt b/core/src/main/java/org/openedx/core/data/model/EnrolledCourse.kt index 018370b6d..0abb159ff 100644 --- a/core/src/main/java/org/openedx/core/data/model/EnrolledCourse.kt +++ b/core/src/main/java/org/openedx/core/data/model/EnrolledCourse.kt @@ -4,9 +4,9 @@ import android.text.TextUtils import com.google.gson.annotations.SerializedName import org.openedx.core.data.model.room.discovery.EnrolledCourseEntity import org.openedx.core.data.model.room.discovery.ProgressDb -import org.openedx.core.domain.ProductInfo import org.openedx.core.domain.model.EnrolledCourse import org.openedx.core.domain.model.EnrollmentMode +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.utils.TimeUtils import org.openedx.core.domain.model.Progress as ProgressDomain diff --git a/core/src/main/java/org/openedx/core/domain/interactor/IAPInteractor.kt b/core/src/main/java/org/openedx/core/domain/interactor/IAPInteractor.kt index c456f2d29..50ae61372 100644 --- a/core/src/main/java/org/openedx/core/domain/interactor/IAPInteractor.kt +++ b/core/src/main/java/org/openedx/core/domain/interactor/IAPInteractor.kt @@ -7,7 +7,7 @@ import com.android.billingclient.api.ProductDetails import com.android.billingclient.api.Purchase import org.openedx.core.ApiConstants import org.openedx.core.data.repository.iap.IAPRepository -import org.openedx.core.domain.ProductInfo +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.exception.iap.IAPException import org.openedx.core.extension.decodeToLong import org.openedx.core.module.billing.BillingProcessor diff --git a/core/src/main/java/org/openedx/core/domain/model/CourseStructure.kt b/core/src/main/java/org/openedx/core/domain/model/CourseStructure.kt index 5869bf222..8430dfdaf 100644 --- a/core/src/main/java/org/openedx/core/domain/model/CourseStructure.kt +++ b/core/src/main/java/org/openedx/core/domain/model/CourseStructure.kt @@ -1,6 +1,6 @@ package org.openedx.core.domain.model -import org.openedx.core.domain.ProductInfo +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.utils.TimeUtils import java.util.Date diff --git a/core/src/main/java/org/openedx/core/domain/model/EnrolledCourse.kt b/core/src/main/java/org/openedx/core/domain/model/EnrolledCourse.kt index 1a785015b..7cbc6811c 100644 --- a/core/src/main/java/org/openedx/core/domain/model/EnrolledCourse.kt +++ b/core/src/main/java/org/openedx/core/domain/model/EnrolledCourse.kt @@ -2,7 +2,7 @@ package org.openedx.core.domain.model import android.os.Parcelable import kotlinx.parcelize.Parcelize -import org.openedx.core.domain.ProductInfo +import org.openedx.core.domain.model.iap.ProductInfo import java.util.Date @Parcelize diff --git a/core/src/main/java/org/openedx/core/domain/ProductInfo.kt b/core/src/main/java/org/openedx/core/domain/model/iap/ProductInfo.kt similarity index 80% rename from core/src/main/java/org/openedx/core/domain/ProductInfo.kt rename to core/src/main/java/org/openedx/core/domain/model/iap/ProductInfo.kt index 12620e5c2..b9e5da3d4 100644 --- a/core/src/main/java/org/openedx/core/domain/ProductInfo.kt +++ b/core/src/main/java/org/openedx/core/domain/model/iap/ProductInfo.kt @@ -1,4 +1,4 @@ -package org.openedx.core.domain +package org.openedx.core.domain.model.iap import android.os.Parcelable import kotlinx.parcelize.Parcelize diff --git a/core/src/main/java/org/openedx/core/domain/model/iap/PurchaseFlowData.kt b/core/src/main/java/org/openedx/core/domain/model/iap/PurchaseFlowData.kt index 554fbc5b8..1102e2348 100644 --- a/core/src/main/java/org/openedx/core/domain/model/iap/PurchaseFlowData.kt +++ b/core/src/main/java/org/openedx/core/domain/model/iap/PurchaseFlowData.kt @@ -2,7 +2,6 @@ package org.openedx.core.domain.model.iap import android.os.Parcelable import kotlinx.parcelize.Parcelize -import org.openedx.core.domain.ProductInfo @Parcelize data class PurchaseFlowData( diff --git a/core/src/main/java/org/openedx/core/module/billing/BillingProcessor.kt b/core/src/main/java/org/openedx/core/module/billing/BillingProcessor.kt index f0cde1550..dff7a717c 100644 --- a/core/src/main/java/org/openedx/core/module/billing/BillingProcessor.kt +++ b/core/src/main/java/org/openedx/core/module/billing/BillingProcessor.kt @@ -23,7 +23,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.launch import kotlinx.coroutines.suspendCancellableCoroutine import kotlinx.coroutines.withContext -import org.openedx.core.domain.ProductInfo +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.extension.decodeToString import org.openedx.core.extension.encodeToString import org.openedx.core.extension.safeResume diff --git a/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt b/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt index e227be4e9..b5a57ae90 100644 --- a/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt +++ b/core/src/main/java/org/openedx/core/presentation/dialog/IAPDialogFragment.kt @@ -35,7 +35,7 @@ import com.android.billingclient.api.BillingClient import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import org.openedx.core.R -import org.openedx.core.domain.ProductInfo +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.domain.model.iap.PurchaseFlowData import org.openedx.core.extension.parcelable import org.openedx.core.extension.serializable diff --git a/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt b/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt index a19b62e34..95bced19f 100644 --- a/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt +++ b/core/src/main/java/org/openedx/core/presentation/iap/IAPUIState.kt @@ -49,7 +49,7 @@ enum class IAPRequestType(val request: String) { CHECKOUT_CODE("checkout"), PAYMENT_SDK_CODE("payment"), EXECUTE_ORDER_CODE("execute"), - NO_SKU_CODE("no_sku"), + NO_SKU_CODE("sku"), CONSUME_CODE("consume"), UNFULFILLED_CODE("unfulfilled"), RESTORE_CODE("restore"), diff --git a/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt b/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt index dcdde987c..2946ef5df 100644 --- a/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt +++ b/core/src/main/java/org/openedx/core/presentation/iap/IAPViewModel.kt @@ -261,6 +261,7 @@ class IAPViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) @@ -340,7 +341,7 @@ class IAPViewModel( ) { analytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - purchaseFlowData.let { + purchaseFlowData.takeIf { it.courseId.isNullOrBlank().not() }?.let { put(IAPAnalyticsKeys.COURSE_ID.key, purchaseFlowData.courseId) put( IAPAnalyticsKeys.PACING.key, diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index a0cc25c6f..6360227e1 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -46,6 +46,7 @@ OS version: Device model: Feedback + Error upgrading course in app MMM dd, yyyy dd MMM yyyy hh:mm aaa App Update diff --git a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt index 471aa59fc..5355e2cd4 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListFragment.kt @@ -75,7 +75,6 @@ import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.openedx.core.AppUpdateState import org.openedx.core.UIMessage -import org.openedx.core.domain.ProductInfo import org.openedx.core.domain.model.Certificate import org.openedx.core.domain.model.CourseAssignments import org.openedx.core.domain.model.CourseSharingUtmParameters @@ -84,6 +83,7 @@ import org.openedx.core.domain.model.CoursewareAccess import org.openedx.core.domain.model.EnrolledCourse import org.openedx.core.domain.model.EnrolledCourseData import org.openedx.core.domain.model.Progress +import org.openedx.core.domain.model.iap.ProductInfo import org.openedx.core.exception.iap.IAPException import org.openedx.core.presentation.IAPAnalyticsScreen import org.openedx.core.presentation.dialog.IAPDialogFragment diff --git a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt index 82affb640..863e742b0 100644 --- a/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt +++ b/dashboard/src/main/java/org/openedx/dashboard/presentation/DashboardListViewModel.kt @@ -275,19 +275,20 @@ class DashboardListViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP.action) }.toMutableMap()) } fun logIAPCancelEvent() { logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE.action) }.toMutableMap()) } @@ -297,7 +298,7 @@ class DashboardListViewModel( ) { iapAnalytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.COURSE_ENROLLMENT) + put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.COURSE_ENROLLMENT.screenName) put(IAPAnalyticsKeys.IAP_FLOW_TYPE.key, IAPFlow.SILENT.value) put(IAPAnalyticsKeys.CATEGORY.key, IAPAnalyticsKeys.IN_APP_PURCHASES.key) }) diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt index 95de33a51..7a3f3f7eb 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsFragment.kt @@ -136,7 +136,7 @@ class SettingsFragment : Fragment() { buildMap { put( IAPAnalyticsKeys.ACTION.key, - IAPAction.ACTION_CLOSE + IAPAction.ACTION_CLOSE.action ) }.toMutableMap() ) diff --git a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt index bdc70bd13..b4c82ae98 100644 --- a/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt +++ b/profile/src/main/java/org/openedx/profile/presentation/settings/SettingsViewModel.kt @@ -191,6 +191,7 @@ class SettingsViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), appVersion = appData.versionName ) logProfileEvent(ProfileAnalyticsEvent.CONTACT_SUPPORT_CLICKED) @@ -271,8 +272,8 @@ class SettingsViewModel( fun logIAPCancelEvent() { logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_RESTORE) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_RESTORE.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_CLOSE.action) }.toMutableMap()) } @@ -280,12 +281,13 @@ class SettingsViewModel( EmailUtil.showFeedbackScreen( context = context, feedbackEmailAddress = config.getFeedbackEmailAddress(), + subject = context.getString(R.string.core_error_upgrading_course_in_app), feedback = message, appVersion = appData.versionName ) logIAPEvent(IAPAnalyticsEvent.IAP_ERROR_ALERT_ACTION, buildMap { - put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED) - put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP) + put(IAPAnalyticsKeys.ERROR_ALERT_TYPE.key, IAPAction.ACTION_UNFULFILLED.action) + put(IAPAnalyticsKeys.ERROR_ACTION.key, IAPAction.ACTION_GET_HELP.action) }.toMutableMap()) } @@ -295,7 +297,7 @@ class SettingsViewModel( ) { analytics.logEvent(event.eventName, params.apply { put(IAPAnalyticsKeys.NAME.key, event.biValue) - put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.PROFILE) + put(IAPAnalyticsKeys.SCREEN_NAME.key, IAPAnalyticsScreen.PROFILE.screenName) put(IAPAnalyticsKeys.IAP_FLOW_TYPE.key, IAPFlow.RESTORE.value) put(IAPAnalyticsKeys.CATEGORY.key, IAPAnalyticsKeys.IN_APP_PURCHASES.key) })