diff --git a/CHANGELOG.md b/CHANGELOG.md index 7682499eebd..1897e755592 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ ### PaymentSheet * [ADDED][7302](https://github.com/stripe/stripe-android/pull/7302) PaymentSheet now supports Alma for PaymentIntents in private beta. +Dependencies updated: +* [7297](https://github.com/stripe/stripe-android/pull/7297) Bumped Compose Foundation, Compose Material, Compose Runtime, and Compose UI from 1.4.3 to 1.5.1. + ## 20.30.2 - 2023-09-13 ### PaymentSheet diff --git a/build-configuration/android-application.gradle b/build-configuration/android-application.gradle index 8579d331f8d..6f76cd12dda 100644 --- a/build-configuration/android-application.gradle +++ b/build-configuration/android-application.gradle @@ -13,6 +13,15 @@ apply from: rootProject.file('build-configuration/ktlint.gradle') check.dependsOn('ktlint') +configurations { + configureEach { + resolutionStrategy { + // Not depending on 1.4.0 because it requires compile SDK 34 + force 'androidx.emoji2:emoji2:1.3.0' + } + } +} + android { namespace STRIPE_ANDROID_NAMESPACE compileSdkVersion rootProject.ext.compileSdkVersion diff --git a/build-configuration/android-library.gradle b/build-configuration/android-library.gradle index 1cd16006842..0cc2493907f 100644 --- a/build-configuration/android-library.gradle +++ b/build-configuration/android-library.gradle @@ -15,6 +15,12 @@ check.dependsOn('ktlint') configurations { javadocDeps + configureEach { + resolutionStrategy { + // Not depending on 1.4.0 because it requires compile SDK 34 + force 'androidx.emoji2:emoji2:1.3.0' + } + } } if (System.getenv("JITPACK")) { diff --git a/dependencies.gradle b/dependencies.gradle index ed8d10ecc49..b29ab4b0cdc 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -11,10 +11,10 @@ ext.versions = [ androidxAppcompat : '1.6.1', androidxArchCore : '2.2.0', androidxBrowser : '1.5.0', - androidxCompose : '1.4.3', + androidxCompose : '1.5.1', androidxComposeCompiler : '1.4.1', - androidxComposeRuntime : '1.4.3', - androidxComposeUi : '1.4.3', + androidxComposeRuntime : '1.5.1', + androidxComposeUi : '1.5.1', androidxConstraintlayout : '2.1.4', androidxCore : '1.9.0', androidxFragment : '1.5.5', @@ -25,7 +25,6 @@ ext.versions = [ androidxRecyclerview : '1.2.1', androidxSecurity : '1.1.0-alpha05', binaryCompatibilityValidator: '0.13.1', - buildTools : "30.0.3", cameraX : '1.2.3', dagger : '2.48', detekt : "1.22.0", diff --git a/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheet.kt b/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheet.kt index bfd2a1f1575..011c347d675 100644 --- a/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheet.kt +++ b/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheet.kt @@ -39,6 +39,7 @@ internal const val BottomSheetContentTestTag = "BottomSheetContentTestTag" internal class BottomSheetState( val modalBottomSheetState: ModalBottomSheetState, val keyboardHandler: BottomSheetKeyboardHandler, + val sheetGesturesEnabled: Boolean, ) { private var dismissalType: DismissalType? = null @@ -101,6 +102,7 @@ internal fun rememberBottomSheetState( BottomSheetState( modalBottomSheetState = modalBottomSheetState, keyboardHandler = keyboardHandler, + sheetGesturesEnabled = false, ) } } @@ -172,6 +174,7 @@ internal fun BottomSheet( topStart = MaterialTheme.stripeShapes.cornerRadius.dp, topEnd = MaterialTheme.stripeShapes.cornerRadius.dp, ), + sheetGesturesEnabled = state.sheetGesturesEnabled, sheetContent = { Box(modifier = Modifier.testTag(BottomSheetContentTestTag)) { sheetContent() diff --git a/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheetKeyboardHandler.kt b/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheetKeyboardHandler.kt index 08ad3fd5070..b20ee570b78 100644 --- a/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheetKeyboardHandler.kt +++ b/paymentsheet/src/main/java/com/stripe/android/common/ui/BottomSheetKeyboardHandler.kt @@ -1,17 +1,15 @@ package com.stripe.android.common.ui +import androidx.compose.foundation.layout.WindowInsets +import androidx.compose.foundation.layout.ime import androidx.compose.runtime.Composable -import androidx.compose.runtime.DisposableEffect import androidx.compose.runtime.State -import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.runtime.rememberUpdatedState import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.ExperimentalComposeUiApi +import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalSoftwareKeyboardController -import androidx.compose.ui.platform.LocalView import androidx.compose.ui.platform.SoftwareKeyboardController -import androidx.core.view.ViewCompat -import androidx.core.view.WindowInsetsCompat import kotlinx.coroutines.flow.first @OptIn(ExperimentalComposeUiApi::class) @@ -35,20 +33,8 @@ internal class BottomSheetKeyboardHandler( @OptIn(ExperimentalComposeUiApi::class) @Composable internal fun rememberBottomSheetKeyboardHandler(): BottomSheetKeyboardHandler { - val view = LocalView.current - val isImeVisible = remember { mutableStateOf(false) } - - DisposableEffect(view) { - ViewCompat.setOnApplyWindowInsetsListener(view) { _, insets -> - isImeVisible.value = insets.isVisible(WindowInsetsCompat.Type.ime()) - insets - } - - onDispose { - ViewCompat.setOnApplyWindowInsetsListener(view, null) - } - } - + val imeHeight = WindowInsets.ime.getBottom(LocalDensity.current) + val isImeVisibleState = rememberUpdatedState(newValue = imeHeight > 0) val keyboardController = LocalSoftwareKeyboardController.current - return BottomSheetKeyboardHandler(keyboardController, isImeVisible) + return BottomSheetKeyboardHandler(keyboardController, isImeVisibleState) } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AddressElementActivity.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AddressElementActivity.kt index 2b18a277e10..9d8ddf1ebbf 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AddressElementActivity.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/addresselement/AddressElementActivity.kt @@ -57,12 +57,7 @@ internal class AddressElementActivity : ComponentActivity() { val navController = rememberAnimatedNavController() viewModel.navigator.navigationController = navController - val bottomSheetState = rememberBottomSheetState( - confirmValueChange = { - val route = navController.currentDestination?.route - route != AddressElementScreen.Autocomplete.route - }, - ) + val bottomSheetState = rememberBottomSheetState() BackHandler { viewModel.navigator.onBack() diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt index c275194c5fe..385457c676e 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/paymentdatacollection/polling/PollingActivity.kt @@ -8,6 +8,7 @@ import androidx.activity.compose.setContent import androidx.activity.viewModels import androidx.appcompat.app.AppCompatActivity import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.ModalBottomSheetValue import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.collectAsState import androidx.compose.runtime.getValue @@ -46,9 +47,18 @@ internal class PollingActivity : AppCompatActivity() { setContent { StripeTheme { - val state = rememberBottomSheetState(confirmValueChange = { false }) val uiState by viewModel.uiState.collectAsState() + val state = rememberBottomSheetState( + confirmValueChange = { proposedValue -> + if (proposedValue == ModalBottomSheetValue.Hidden) { + uiState.pollingState != PollingState.Active + } else { + true + } + } + ) + BackHandler(enabled = true) { if (uiState.pollingState == PollingState.Failed) { viewModel.handleCancel() diff --git a/stripe-ui-core/src/test/resources/robolectric.properties b/stripe-ui-core/src/test/resources/robolectric.properties new file mode 100644 index 00000000000..4f3945f61dc --- /dev/null +++ b/stripe-ui-core/src/test/resources/robolectric.properties @@ -0,0 +1 @@ +sdk=33