Skip to content

Commit 91976bd

Browse files
committed
Merge branch '316-webview-opened-with-wrong-theme-setting' into 'master'
Resolve "Webview opened with wrong theme setting" Closes #316 See merge request pace/mobile/android/pace-cloud-sdk!369
2 parents b704d6c + af842f5 commit 91976bd

File tree

4 files changed

+33
-4
lines changed

4 files changed

+33
-4
lines changed

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This framework combines multipe functionalities provided by PACE i.e. authorizin
2424
+ [21.x.x -> 22.x.x](#from-21xx-to-22xx)
2525
+ [22.x.x -> 23.x.x](#from-22xx-to-23xx)
2626
+ [23.x.x -> 24.x.x](#from-23xx-to-24xx)
27+
+ [24.x.x -> 25.x.x](#from-24xx-to-25xx)
2728

2829
## Documentation
2930
The full documentation and instructions on how to integrate PACE Cloud SDK can be found [here](https://docs.pace.cloud/en/integrating/mobile-app)

library/src/main/java/cloud/pace/sdk/idkit/authorization/AuthorizationManager.kt

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ import android.net.Uri
99
import android.os.Build
1010
import android.widget.Toast
1111
import 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
1215
import androidx.fragment.app.Fragment
1316
import androidx.lifecycle.DefaultLifecycleObserver
1417
import androidx.lifecycle.LifecycleOwner
1518
import androidx.lifecycle.ProcessLifecycleOwner
1619
import cloud.pace.sdk.PACECloudSDK
1720
import cloud.pace.sdk.R
1821
import cloud.pace.sdk.api.API
22+
import cloud.pace.sdk.appkit.AppKit
1923
import cloud.pace.sdk.idkit.authorization.integrated.AuthorizationWebViewActivity
2024
import cloud.pace.sdk.idkit.model.FailedRetrievingConfigurationWhileDiscovering
2125
import cloud.pace.sdk.idkit.model.FailedRetrievingSessionWhileAuthorizing
@@ -37,6 +41,7 @@ import cloud.pace.sdk.utils.IntentResult
3741
import cloud.pace.sdk.utils.Ok
3842
import cloud.pace.sdk.utils.SetupLogger
3943
import cloud.pace.sdk.utils.Success
44+
import cloud.pace.sdk.utils.Theme
4045
import cloud.pace.sdk.utils.getResultFor
4146
import cloud.pace.sdk.utils.resumeIfActive
4247
import 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()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
4+
<style name="AppKitTheme" parent="Theme.AppCompat.DayNight.NoActionBar">
5+
<item name="windowActionBar">false</item>
6+
<item name="windowNoTitle">true</item>
7+
<item name="android:windowAnimationStyle">@null</item>
8+
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
9+
<item name="android:windowLightNavigationBar">?attr/isLightTheme</item>
10+
</style>
11+
12+
</resources>

library/src/main/res/values/styles.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<item name="windowActionBar">false</item>
66
<item name="windowNoTitle">true</item>
77
<item name="android:windowAnimationStyle">@null</item>
8+
<item name="android:windowLightStatusBar">?attr/isLightTheme</item>
89
</style>
910

1011
<style name="ProgressButton" parent="Widget.AppCompat.Button">

0 commit comments

Comments
 (0)