Skip to content

Commit

Permalink
fix: code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan-arshad-dev committed Jul 8, 2024
1 parent b5d79c2 commit 1fc7be2
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.openedx.core.domain
package org.openedx.core.domain.model.iap

import android.os.Parcelable
import kotlinx.parcelize.Parcelize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<string name="core_android_os_version" translatable="false">OS version: </string>
<string name="core_android_device_model" translatable="false">Device model: </string>
<string name="core_email_subject" translatable="false">Feedback</string>
<string name="core_error_upgrading_course_in_app" translatable="false">Error upgrading course in app</string>
<string name="core_date_format_MMM_dd_yyyy">MMM dd, yyyy</string>
<string name="core_full_date_with_time">dd MMM yyyy hh:mm aaa</string>
<string name="core_app_upgrade_title">App Update</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}

Expand All @@ -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)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class SettingsFragment : Fragment() {
buildMap {
put(
IAPAnalyticsKeys.ACTION.key,
IAPAction.ACTION_CLOSE
IAPAction.ACTION_CLOSE.action
)
}.toMutableMap()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -271,21 +272,22 @@ 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())
}

fun showFeedbackScreen(context: Context, message: String) {
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())
}

Expand All @@ -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)
})
Expand Down

0 comments on commit 1fc7be2

Please sign in to comment.