@@ -9,13 +9,17 @@ import android.net.Uri
99import android.os.Build
1010import android.widget.Toast
1111import androidx.appcompat.app.AppCompatActivity
12+ import androidx.browser.customtabs.CustomTabsIntent
13+ import androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_DARK
14+ import androidx.browser.customtabs.CustomTabsIntent.COLOR_SCHEME_LIGHT
1215import androidx.fragment.app.Fragment
1316import androidx.lifecycle.DefaultLifecycleObserver
1417import androidx.lifecycle.LifecycleOwner
1518import androidx.lifecycle.ProcessLifecycleOwner
1619import cloud.pace.sdk.PACECloudSDK
1720import cloud.pace.sdk.R
1821import cloud.pace.sdk.api.API
22+ import cloud.pace.sdk.appkit.AppKit
1923import cloud.pace.sdk.idkit.authorization.integrated.AuthorizationWebViewActivity
2024import cloud.pace.sdk.idkit.model.FailedRetrievingConfigurationWhileDiscovering
2125import cloud.pace.sdk.idkit.model.FailedRetrievingSessionWhileAuthorizing
@@ -37,6 +41,7 @@ import cloud.pace.sdk.utils.IntentResult
3741import cloud.pace.sdk.utils.Ok
3842import cloud.pace.sdk.utils.SetupLogger
3943import cloud.pace.sdk.utils.Success
44+ import cloud.pace.sdk.utils.Theme
4045import cloud.pace.sdk.utils.getResultFor
4146import cloud.pace.sdk.utils.resumeIfActive
4247import kotlinx.coroutines.suspendCancellableCoroutine
@@ -151,7 +156,8 @@ internal class AuthorizationManager(
151156 authorizationService.performAuthorizationRequest(
152157 authorizationRequest,
153158 PendingIntent .getActivity(context, 0 , Intent (context, completedActivity), flags),
154- canceledPendingIntent
159+ canceledPendingIntent,
160+ getCustomTabIntentForAuthorization()
155161 )
156162 } catch (e: ActivityNotFoundException ) {
157163 Timber .i(e, " No supported browser installed to launch the authorization request" )
@@ -165,7 +171,7 @@ internal class AuthorizationManager(
165171 Success (AuthorizationWebViewActivity .createStartIntent(context, authorizationRequest))
166172 } else {
167173 try {
168- Success (authorizationService.getAuthorizationRequestIntent(authorizationRequest))
174+ Success (authorizationService.getAuthorizationRequestIntent(authorizationRequest, getCustomTabIntentForAuthorization() ))
169175 } catch (e: ActivityNotFoundException ) {
170176 Timber .i(e, " No supported browser installed to launch the authorization request" )
171177 showNoSupportedBrowserToast()
@@ -258,7 +264,8 @@ internal class AuthorizationManager(
258264 authorizationService.performEndSessionRequest(
259265 it,
260266 PendingIntent .getActivity(context, 0 , Intent (context, completedActivity), flags),
261- canceledPendingIntent
267+ canceledPendingIntent,
268+ getCustomTabIntentForAuthorization()
262269 )
263270 } catch (e: ActivityNotFoundException ) {
264271 Timber .i(e, " No supported browser installed to launch the end session request" )
@@ -276,7 +283,7 @@ internal class AuthorizationManager(
276283 Success (AuthorizationWebViewActivity .createStartIntent(context, endSessionRequest))
277284 } else {
278285 try {
279- Success (authorizationService.getEndSessionRequestIntent(endSessionRequest))
286+ Success (authorizationService.getEndSessionRequestIntent(endSessionRequest, getCustomTabIntentForAuthorization() ))
280287 } catch (e: ActivityNotFoundException ) {
281288 Timber .i(e, " No supported browser installed to launch the end session request" )
282289 showNoSupportedBrowserToast()
@@ -419,6 +426,14 @@ internal class AuthorizationManager(
419426 }
420427 }
421428
429+ private fun getCustomTabIntentForAuthorization (): CustomTabsIntent {
430+ val colorScheme = when (AppKit .theme) {
431+ Theme .DARK -> COLOR_SCHEME_DARK
432+ Theme .LIGHT -> COLOR_SCHEME_LIGHT
433+ }
434+ return authorizationService.createCustomTabsIntentBuilder().setColorScheme(colorScheme).build()
435+ }
436+
422437 override fun onDestroy (owner : LifecycleOwner ) {
423438 // This must be called to avoid memory leaks.
424439 authorizationService.dispose()
0 commit comments