diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt index 1dfce5bf72..1b796eddf7 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/NaviBbpsConstants.kt @@ -123,6 +123,7 @@ const val AB_TESTING_PROJECT_ORIGIN_EMAIL_SUB_EXPERIMENT_NAME = "NaviBBPS-Projec const val NAVI_BBPS_REWARD_BANNER = "reward" const val NAVI_BBPS_CROSS_SELL_BANNER = "cross-sell" const val ERROR_CODE_ORIGIN_NOTIFY_LATER = "ORIGIN_NOTIFY_LATER" +const val ERR_NO_READ_ONLY_GMAIL_SCOPE = "ERR_NO_READ_ONLY_GMAIL_SCOPE" // Order Details Screen redirection const val NAVI_BBPS_TSTORE_ORDER_DETAILS_REDIRECTION = "naviPay/NAVI_PAY_ORDER_DETAILS" diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/model/GmailAccessResponse.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/model/GmailAccessResponse.kt index 5c5c27f3f8..ff1c2d9076 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/model/GmailAccessResponse.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/model/GmailAccessResponse.kt @@ -26,4 +26,5 @@ data class GoogleUserProfileData( @SerializedName("givenName") val givenName: String? = null, @SerializedName("idToken") val idToken: String? = null, @SerializedName("photoUrl") val photoUrl: String? = null, + @SerializedName("grantedScopes") val grantedScopes: String?, ) diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/signin/GmailAccessSignInManager.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/signin/GmailAccessSignInManager.kt index f54932fd3f..150d797568 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/signin/GmailAccessSignInManager.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/gmail/signin/GmailAccessSignInManager.kt @@ -120,6 +120,7 @@ class GmailAccessSignInManager @Inject constructor(@ActivityContext val context: return try { val task = GoogleSignIn.getSignedInAccountFromIntent(intent) val taskResult = task.getResult(ApiException::class.java) + GmailAccessResponse( authCode = taskResult.serverAuthCode, emailId = taskResult.account?.name, @@ -131,6 +132,7 @@ class GmailAccessSignInManager @Inject constructor(@ActivityContext val context: givenName = taskResult.givenName, idToken = taskResult.idToken, photoUrl = taskResult.photoUrl?.toString().orEmpty(), + grantedScopes = taskResult.grantedScopes.joinToString(",") { it.scopeUri }, ), signInAccount = taskResult, account = taskResult.account, @@ -141,7 +143,7 @@ class GmailAccessSignInManager @Inject constructor(@ActivityContext val context: } companion object { - private const val GMAIL_READ_ONLY_SCOPE = "https://www.googleapis.com/auth/gmail.readonly" + const val GMAIL_READ_ONLY_SCOPE = "https://www.googleapis.com/auth/gmail.readonly" private const val USER_PROFILE_SCOPE = "https://www.googleapis.com/auth/userinfo.profile" private const val USER_EMAIL_SCOPE = "https://www.googleapis.com/auth/userinfo.email" } diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/ui/NaviBbpsCommonComposable.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/ui/NaviBbpsCommonComposable.kt index f2719bb8bb..0d8a37c6c2 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/ui/NaviBbpsCommonComposable.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/ui/NaviBbpsCommonComposable.kt @@ -333,9 +333,9 @@ fun BottomSheetContentWithIconHeaderPrimarySecondaryButton( NaviText( text = header, - fontSize = 18.sp, + fontSize = 16.sp, fontFamily = naviFontFamily, - fontWeight = getFontWeight(FontWeightEnum.NAVI_HEADLINE_REGULAR), + fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_DEMI_BOLD), color = NaviBbpsColor.textPrimary, ) @@ -346,7 +346,7 @@ fun BottomSheetContentWithIconHeaderPrimarySecondaryButton( fontSize = 14.sp, fontFamily = naviFontFamily, fontWeight = getFontWeight(FontWeightEnum.NAVI_BODY_REGULAR), - color = NaviBbpsColor.textSecondary, + color = NaviBbpsColor.textTertiary, ) if (!primaryButton.isNullOrBlank() || !secondaryButton.isNullOrBlank()) { diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandler.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandler.kt index d0f9e9458e..0ec7eb7535 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandler.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandler.kt @@ -18,7 +18,9 @@ import com.navi.bbps.common.ADDING_BILLS_SUCCESS_LOTTIE import com.navi.bbps.common.ADDING_DETECTED_BILLS_LOTTIE import com.navi.bbps.common.DEFAULT_RETRY_COUNT import com.navi.bbps.common.ERROR_CODE_ORIGIN_NOTIFY_LATER +import com.navi.bbps.common.ERR_NO_READ_ONLY_GMAIL_SCOPE import com.navi.bbps.common.RETRY_INTERVAL_IN_SECONDS +import com.navi.bbps.common.gmail.signin.GmailAccessSignInManager.Companion.GMAIL_READ_ONLY_SCOPE import com.navi.bbps.common.mapper.DetectedBillsMapper import com.navi.bbps.common.model.config.NaviBbpsDefaultConfig import com.navi.bbps.common.model.network.BillDetectionRequest @@ -98,6 +100,7 @@ constructor( coroutineScope: CoroutineScope, permission: String, googleToken: String? = null, + grantedEmailScopes: String? = null, email: String? = null, naviBbpsDefaultConfig: NaviBbpsDefaultConfig, updateOpenBottomSheet: suspend (Boolean) -> Unit, @@ -114,6 +117,19 @@ constructor( updateBottomSheetCancellable(true) } + if ( + permission == DetectedBillSource.EMAIL.name && + GMAIL_READ_ONLY_SCOPE !in (grantedEmailScopes.orEmpty()) + ) { + updateOpenBottomSheet(false) + val errorConfig = + naviBbpsBaseVM + .getGenericErrorConfig() + .copy(code = ERR_NO_READ_ONLY_GMAIL_SCOPE, tag = ERR_NO_READ_ONLY_GMAIL_SCOPE) + naviBbpsBaseVM.notifyError(errorConfig) + return + } + updateBottomSheetCancellable(false) resetLoadingIndicatorProgress() diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/BillCategoryViewModelV2.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/BillCategoryViewModelV2.kt index 32690a19fe..9d96c1851f 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/BillCategoryViewModelV2.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/BillCategoryViewModelV2.kt @@ -485,6 +485,7 @@ constructor( detectedBillSource: DetectedBillSource = DetectedBillSource.SMS, googleToken: String? = null, email: String? = null, + grantedEmailScopes: String? = null, ) { viewModelScope.launch(dispatcherProvider.io) { originBillDetectionHandler.startDetectingBills( @@ -492,6 +493,7 @@ constructor( coroutineScope = viewModelScope, permission = detectedBillSource.name, googleToken = googleToken, + grantedEmailScopes = grantedEmailScopes, email = email, naviBbpsDefaultConfig = naviBbpsDefaultConfig, updateOpenBottomSheet = { isOpen -> updateOpenBottomSheet(isOpen) }, diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/BillCategoryScreenV2.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/BillCategoryScreenV2.kt index 160ed951b1..009cdad534 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/BillCategoryScreenV2.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/category/ui/BillCategoryScreenV2.kt @@ -720,6 +720,8 @@ fun BillCategoryScreenRenderer( detectedBillSource = DetectedBillSource.EMAIL, googleToken = gmailAccessState.signInResponse.authCode, email = gmailAccessState.signInResponse.emailId, + grantedEmailScopes = + gmailAccessState.signInResponse.profileData?.grantedScopes, ) } diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/DetectedBillsViewModel.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/DetectedBillsViewModel.kt index b63ef8feed..a9a1583c16 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/DetectedBillsViewModel.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/DetectedBillsViewModel.kt @@ -267,6 +267,7 @@ constructor( detectedBillSource: DetectedBillSource = DetectedBillSource.SMS, googleToken: String? = null, email: String? = null, + grantedEmailScopes: String? = null, ) { viewModelScope.launch(dispatcherProvider.io) { originBillDetectionHandler.startDetectingBills( @@ -274,6 +275,7 @@ constructor( coroutineScope = viewModelScope, permission = detectedBillSource.name, googleToken = googleToken, + grantedEmailScopes = grantedEmailScopes, email = email, naviBbpsDefaultConfig = naviBbpsDefaultConfig, updateOpenBottomSheet = { isOpen -> updateOpenBottomSheet(isOpen) }, diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/ui/DetectedBillsScreen.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/ui/DetectedBillsScreen.kt index 2d15ee54f0..aa105b72e3 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/ui/DetectedBillsScreen.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/detectedbills/ui/DetectedBillsScreen.kt @@ -303,6 +303,8 @@ fun DetectedBillsScreen( detectedBillSource = DetectedBillSource.EMAIL, googleToken = gmailAccessState.signInResponse.authCode, email = gmailAccessState.signInResponse.emailId, + grantedEmailScopes = + gmailAccessState.signInResponse.profileData?.grantedScopes, ) } diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/MyBillsViewModel.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/MyBillsViewModel.kt index 5b4c230154..d290ebc5f0 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/MyBillsViewModel.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/MyBillsViewModel.kt @@ -828,6 +828,7 @@ constructor( detectedBillSource: DetectedBillSource = DetectedBillSource.SMS, googleToken: String? = null, email: String? = null, + grantedEmailScopes: String? = null, ) { viewModelScope.launch(dispatcherProvider.io) { originBillDetectionHandler.startDetectingBills( @@ -835,6 +836,7 @@ constructor( coroutineScope = viewModelScope, permission = detectedBillSource.name, googleToken = googleToken, + grantedEmailScopes = grantedEmailScopes, email = email, naviBbpsDefaultConfig = naviBbpsDefaultConfig, updateOpenBottomSheet = { isOpen -> updateOpenBottomSheet(isOpen) }, diff --git a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/ui/MyBillsScreen.kt b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/ui/MyBillsScreen.kt index ad5f0150a5..01e8d892bf 100644 --- a/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/ui/MyBillsScreen.kt +++ b/android/navi-bbps/src/main/kotlin/com/navi/bbps/feature/mybills/ui/MyBillsScreen.kt @@ -352,6 +352,8 @@ fun MyBillsScreen( detectedBillSource = DetectedBillSource.EMAIL, googleToken = gmailAccessState.signInResponse.authCode, email = gmailAccessState.signInResponse.emailId, + grantedEmailScopes = + gmailAccessState.signInResponse.profileData?.grantedScopes, ) } diff --git a/android/navi-bbps/src/test/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandlerTest.kt b/android/navi-bbps/src/test/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandlerTest.kt index 1f90effa7b..252c9b7b8b 100644 --- a/android/navi-bbps/src/test/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandlerTest.kt +++ b/android/navi-bbps/src/test/kotlin/com/navi/bbps/common/viewmodel/OriginBillDetectionHandlerTest.kt @@ -9,6 +9,7 @@ package com.navi.bbps.common.viewmodel import com.navi.base.utils.NaviNetworkConnectivity import com.navi.base.utils.ResourceProvider +import com.navi.bbps.common.gmail.signin.GmailAccessSignInManager.Companion.GMAIL_READ_ONLY_SCOPE import com.navi.bbps.common.model.config.NaviBbpsDefaultConfig import com.navi.bbps.common.model.network.BillDetectionResponse import com.navi.bbps.common.model.network.DetectedBillsResponse @@ -230,6 +231,7 @@ class OriginBillDetectionHandlerTest { naviBbpsBaseVM = naviBbpsBaseVM, coroutineScope = testScope, permission = "EMAIL", // Using EMAIL permission + grantedEmailScopes = GMAIL_READ_ONLY_SCOPE, naviBbpsDefaultConfig = config, updateOpenBottomSheet = testCallbacks.updateOpenBottomSheet, updateBottomSheetCancellable = testCallbacks.updateBottomSheetCancellable,