Skip to content

Commit 5966e10

Browse files
feat(ad-hoc): Migrate to Compose 2025.11.01 (#356)
1 parent 5c103c4 commit 5966e10

9 files changed

Lines changed: 66 additions & 288 deletions

File tree

build.gradle

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ buildscript {
88
kotlinVersion = '2.1.20'
99
kspVersion = '2.1.20-1.0.32'
1010
dokkaVersion = '1.9.20'
11-
androidxNavigationVersion = '2.9.3'
11+
androidxNavigationVersion = '2.9.6'
1212
secretsVaultPluginVersion = '0.1.3'
1313
nexusPublishPluginVersion = '2.0.0'
1414
}
@@ -62,13 +62,13 @@ ext {
6262
androidxConstraintLayoutVersion = '2.2.1'
6363
androidxActivityVersion = '1.10.1'
6464
androidxFragmentVersion = '1.8.9'
65-
androidxLifecycleVersion = '2.9.0'
65+
androidxLifecycleVersion = '2.9.4'
6666
androidxRecyclerViewVersion = '1.4.0'
6767
androidxSwipeRefreshLayoutVersion = '1.1.0'
6868
androidxBrowserVersion = '1.8.0'
6969
androidxCameraVersion = '1.4.2'
7070

71-
androidxComposeBOMVersion = '2025.04.00'
71+
androidxComposeBOMVersion = '2025.11.01'
7272
composeGooglePayButtonVersion = '1.1.0'
7373

7474
materialVersion = '1.12.0'
@@ -81,9 +81,9 @@ ext {
8181
okhttpVersion = '4.12.0'
8282
okioVersion = '3.10.2'
8383
coilVersion = '2.7.0'
84-
commonMarkVersion = '0.25.1'
85-
libphonenumberVersion = '9.0.12'
86-
zxingVersion = '3.5.3'
84+
commonMarkVersion = '0.27.0'
85+
libphonenumberVersion = '9.0.19'
86+
zxingVersion = '3.5.4'
8787
jjwtVersion = '0.13.0'
8888
bouncyCastleVersion = '1.79'
8989
slf4jVersion = '1.7.36'
@@ -92,15 +92,15 @@ ext {
9292
checkout3dsSdkVersion = '3.2.7'
9393

9494
junitVersion = '4.13.2'
95-
mockitoVersion = '5.19.0'
95+
mockitoVersion = '5.20.0'
9696
mockitoInlineVersion = '5.2.0'
97-
mockitoKotlinVersion = '6.0.0'
98-
robolectricVersion = '4.15.1'
97+
mockitoKotlinVersion = '6.1.0'
98+
robolectricVersion = '4.16'
9999
androidxTestCoreVersion = '1.7.0'
100100

101101
// Legacy
102102
volleyVersion = '1.2.1'
103-
gsonVersion = '2.13.1'
103+
gsonVersion = '2.13.2'
104104
}
105105

106106
apply from: "${rootDir}/scripts/publish-root.gradle"

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/POCopyButton.kt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22

33
package com.processout.sdk.ui.core.component
44

5+
import android.content.ClipData
56
import androidx.compose.animation.*
67
import androidx.compose.animation.core.tween
78
import androidx.compose.runtime.*
89
import androidx.compose.ui.Modifier
9-
import androidx.compose.ui.platform.LocalClipboardManager
10-
import androidx.compose.ui.text.AnnotatedString
10+
import androidx.compose.ui.platform.ClipEntry
11+
import androidx.compose.ui.platform.LocalClipboard
1112
import androidx.compose.ui.text.font.FontWeight
1213
import androidx.compose.ui.unit.Dp
1314
import com.processout.sdk.ui.core.R
@@ -36,7 +37,7 @@ fun POCopyButton(
3637
copiedIcon: PODrawableImage? = POCopyButton.CopiedIcon,
3738
iconSize: Dp = dimensions.iconSizeSmall
3839
) {
39-
val clipboardManager = LocalClipboardManager.current
40+
val clipboard = LocalClipboard.current
4041
var isCopied by remember { mutableStateOf(false) }
4142
var timerJob by remember { mutableStateOf<Job?>(null) }
4243
val coroutineScope = rememberCoroutineScope()
@@ -55,12 +56,14 @@ fun POCopyButton(
5556
POButton(
5657
text = if (isCopiedAnimated) copiedText else copyText,
5758
onClick = {
58-
clipboardManager.setText(AnnotatedString(textToCopy))
59-
isCopied = true
60-
timerJob?.cancel()
61-
timerJob = coroutineScope.launch {
62-
delay(timeMillis = 2500)
63-
isCopied = false
59+
coroutineScope.launch {
60+
clipboard.setClipEntry(ClipEntry(ClipData.newPlainText(textToCopy, textToCopy)))
61+
isCopied = true
62+
timerJob?.cancel()
63+
timerJob = launch {
64+
delay(timeMillis = 2500)
65+
isCopied = false
66+
}
6467
}
6568
},
6669
modifier = modifier,

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/field/code/POCodeField.kt

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import androidx.compose.foundation.focusGroup
66
import androidx.compose.foundation.layout.*
77
import androidx.compose.foundation.text.KeyboardActions
88
import androidx.compose.foundation.text.KeyboardOptions
9+
import androidx.compose.foundation.text.contextmenu.builder.item
10+
import androidx.compose.foundation.text.contextmenu.modifier.appendTextContextMenuComponents
11+
import androidx.compose.foundation.text.contextmenu.modifier.filterTextContextMenuComponents
912
import androidx.compose.runtime.*
1013
import androidx.compose.ui.Alignment
1114
import androidx.compose.ui.Modifier
@@ -30,15 +33,16 @@ import com.processout.sdk.ui.core.component.PORequestFocus
3033
import com.processout.sdk.ui.core.component.POText
3134
import com.processout.sdk.ui.core.component.field.POField
3235
import com.processout.sdk.ui.core.component.field.POField.stateStyle
36+
import com.processout.sdk.ui.core.component.field.code.POCodeField.ContextMenuPasteKey
3337
import com.processout.sdk.ui.core.component.field.code.POCodeField.align
3438
import com.processout.sdk.ui.core.component.field.code.POCodeField.rememberTextFieldWidth
3539
import com.processout.sdk.ui.core.component.field.code.POCodeField.validLength
3640
import com.processout.sdk.ui.core.component.field.text.POTextField
37-
import com.processout.sdk.ui.core.component.texttoolbar.ProcessOutTextToolbar
3841
import com.processout.sdk.ui.core.state.POInputFilter
3942
import com.processout.sdk.ui.core.theme.ProcessOutTheme.colors
4043
import com.processout.sdk.ui.core.theme.ProcessOutTheme.spacing
4144
import com.processout.sdk.ui.core.theme.ProcessOutTheme.typography
45+
import kotlinx.coroutines.launch
4246

4347
/** @suppress */
4448
@ProcessOutInternalApi
@@ -111,31 +115,7 @@ private fun Code(
111115
keyboardActions: KeyboardActions,
112116
modifier: Modifier = Modifier
113117
) {
114-
val validLength = remember(length) { validLength(length) }
115-
var values by remember(validLength) { mutableStateOf(values(value.text, validLength, inputFilter)) }
116-
var focusedIndex by remember(validLength) { mutableIntStateOf(values.focusedIndex()) }
117-
val clipboardManager = LocalClipboardManager.current
118-
CompositionLocalProvider(
119-
LocalLayoutDirection provides LayoutDirection.Ltr,
120-
LocalTextToolbar provides ProcessOutTextToolbar(
121-
view = LocalView.current,
122-
onPasteRequested = {
123-
if (clipboardManager.hasText()) {
124-
val pastedValues = values(
125-
text = clipboardManager.getText()?.text ?: String(),
126-
length = validLength,
127-
inputFilter = inputFilter
128-
)
129-
if (!pastedValues.all { it.text.isEmpty() }) {
130-
values = pastedValues
131-
focusedIndex = values.focusedIndex()
132-
onValueChange(values.codeValue())
133-
}
134-
}
135-
},
136-
hideUnspecifiedActions = true
137-
)
138-
) {
118+
CompositionLocalProvider(LocalLayoutDirection provides LayoutDirection.Ltr) {
139119
var rowWidthPx by remember { mutableIntStateOf(0) }
140120
val horizontalSpace = spacing.space8
141121
Row(
@@ -146,7 +126,15 @@ private fun Code(
146126
horizontalArrangement = Arrangement.spacedBy(horizontalSpace),
147127
verticalAlignment = Alignment.CenterVertically
148128
) {
129+
val context = LocalContext.current
130+
val clipboard = LocalClipboard.current
149131
val focusManager = LocalFocusManager.current
132+
val coroutineScope = rememberCoroutineScope()
133+
134+
val validLength = remember(length) { validLength(length) }
135+
var values by remember(validLength) { mutableStateOf(values(value.text, validLength, inputFilter)) }
136+
var focusedIndex by remember(validLength) { mutableIntStateOf(values.focusedIndex()) }
137+
150138
for (textFieldIndex in values.indices) {
151139
val focusRequester = remember { FocusRequester() }
152140
POTextField(
@@ -225,6 +213,31 @@ private fun Code(
225213
}
226214
false
227215
}
216+
.appendTextContextMenuComponents {
217+
item(
218+
key = ContextMenuPasteKey,
219+
label = context.getString(android.R.string.paste)
220+
) {
221+
coroutineScope.launch {
222+
val pastedText = clipboard.getClipEntry()?.clipData
223+
?.getItemAt(0)?.text?.toString() ?: String()
224+
val pastedValues = values(
225+
text = pastedText,
226+
length = validLength,
227+
inputFilter = inputFilter
228+
)
229+
if (!pastedValues.all { it.text.isEmpty() }) {
230+
values = pastedValues
231+
focusedIndex = values.focusedIndex()
232+
onValueChange(values.codeValue())
233+
}
234+
close()
235+
}
236+
}
237+
}
238+
.filterTextContextMenuComponents {
239+
it.key == ContextMenuPasteKey
240+
}
228241
.focusRequester(focusRequester)
229242
.onFocusChanged {
230243
if (it.isFocused) {
@@ -289,6 +302,8 @@ private fun List<TextFieldValue>.codeValue() = TextFieldValue(
289302
@ProcessOutInternalApi
290303
object POCodeField {
291304

305+
data object ContextMenuPasteKey
306+
292307
val default: POField.Style
293308
@Composable get() = POField.default.let {
294309
val text = POText.Style(

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/field/dropdown/PODropdownField.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ fun PODropdownField(
107107
onValueChange = {},
108108
modifier = Modifier.fillMaxWidth(),
109109
textFieldModifier = textFieldModifier
110-
.menuAnchor(MenuAnchorType.PrimaryNotEditable)
110+
.menuAnchor(ExposedDropdownMenuAnchorType.PrimaryNotEditable)
111111
.onFocusChanged {
112112
isFocused = it.isFocused
113113
},
@@ -140,7 +140,7 @@ fun PODropdownField(
140140
expanded = expanded,
141141
onDismissRequest = { expanded = false },
142142
modifier = Modifier
143-
.exposedDropdownSize(matchTextFieldWidth = menuMatchesTextFieldWidth)
143+
.exposedDropdownSize(matchAnchorWidth = menuMatchesTextFieldWidth)
144144
.heightIn(max = maxMenuHeight)
145145
.border(
146146
width = menuStyle.border.width,

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/texttoolbar/FloatingTextActionModeCallback.kt

Lines changed: 0 additions & 44 deletions
This file was deleted.

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/texttoolbar/PrimaryTextActionModeCallback.kt

Lines changed: 0 additions & 26 deletions
This file was deleted.

ui-core/src/main/kotlin/com/processout/sdk/ui/core/component/texttoolbar/ProcessOutTextToolbar.kt

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)