Skip to content

Commit f58ec6a

Browse files
authored
Update Kotlin to 1.9.20 and Compose to 1.5.4 (#53)
* Update Kotlin to 1.9.20 and Compose to 1.5.4 * detekt
1 parent e245585 commit f58ec6a

File tree

7 files changed

+50
-37
lines changed

7 files changed

+50
-37
lines changed

.idea/kotlinc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Step 2. Add the dependency - n.b. this currently does not support Material 3.
9898
```kotlin
9999
dependencies {
100100
implementation("androidx.compose.material:material:1.5.4")
101-
implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.5")
101+
implementation("com.github.jump-sdk:jetpack_compose_country_code_picker_emoji:2.2.6")
102102
}
103103
```
104104

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ tasks.register<Delete>("clean") {
3131
tasks.withType<com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask> {
3232
checkForGradleUpdate = true
3333
rejectVersionIf {
34-
listOf("-mercury-", "-station-", "-alpha", "-dev-").any { word ->
34+
listOf("2.0.0-Beta1", "2.7.0-beta01", "-alpha", "-dev-").any { word ->
3535
candidate.version.contains(word)
3636
}
3737
}

ccp/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ dependencies {
5858
implementation(libs.compose.tooling.preview)
5959

6060
detektPlugins("ru.kode:detekt-rules-compose:1.3.0")
61-
detektPlugins("io.nlopez.compose.rules:detekt:0.3.0")
61+
detektPlugins("io.nlopez.compose.rules:detekt:0.3.3")
6262
detektPlugins("io.gitlab.arturbosch.detekt:detekt-rules-libraries:${libs.versions.detekt.get()}")
6363
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:${libs.versions.detekt.get()}")
6464
detektPlugins("com.braisgabin.detekt:kotlin-compiler-wrapper:0.0.4")
65-
detektPlugins("com.github.hbmartin:hbmartin-detekt-rules:0.1.1")
65+
detektPlugins("com.github.hbmartin:hbmartin-detekt-rules:0.1.3")
6666
}
6767

6868
detekt {
@@ -78,7 +78,7 @@ afterEvaluate {
7878
groupId = "com.togisoft"
7979
artifactId = "jetpack_country_code_picker"
8080
// Update version in README when changing below
81-
version = "2.2.5"
81+
version = "2.2.6"
8282
}
8383
}
8484
}

ccp/src/main/java/com/togitech/ccp/component/TogiCountryCodePicker.kt

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.togitech.ccp.component
22

3+
import android.content.Context
34
import android.util.Log
45
import androidx.compose.foundation.focusable
56
import androidx.compose.foundation.layout.fillMaxWidth
@@ -27,6 +28,7 @@ import androidx.compose.ui.Modifier
2728
import androidx.compose.ui.autofill.AutofillType
2829
import androidx.compose.ui.focus.FocusRequester
2930
import androidx.compose.ui.focus.focusRequester
31+
import androidx.compose.ui.graphics.Color
3032
import androidx.compose.ui.graphics.Shape
3133
import androidx.compose.ui.graphics.vector.ImageVector
3234
import androidx.compose.ui.platform.LocalContext
@@ -126,20 +128,20 @@ fun TogiCountryCodePicker(
126128
initialCountryPhoneCode,
127129
initialCountryIsoCode,
128130
) {
129-
if (initialPhoneNumber?.startsWith("+") == true) {
130-
Log.e(TAG, "initialPhoneNumber must not include the country code")
131-
}
132-
if (initialCountryPhoneCode?.run { !startsWith("+") } == true) {
133-
Log.e(TAG, "initialCountryPhoneCode must start with +")
134-
}
135131
mutableStateOf(
136-
initialCountryPhoneCode?.let { getCountryFromPhoneCode(it, context) }
137-
?: CountryData.entries.firstOrNull { it.countryIso == initialCountryIsoCode }
138-
?: CountryData.isoMap[getUserIsoCode(context)]
139-
?: fallbackCountry,
132+
configureInitialCountry(
133+
initialCountryPhoneCode = initialCountryPhoneCode,
134+
context = context,
135+
initialCountryIsoCode = initialCountryIsoCode,
136+
fallbackCountry = fallbackCountry,
137+
),
140138
)
141139
}
142140

141+
if (initialPhoneNumber?.startsWith("+") == true) {
142+
Log.e(TAG, "initialPhoneNumber must not include the country code")
143+
}
144+
143145
val phoneNumberTransformation = remember(country) {
144146
PhoneNumberTransformation(country.countryIso, context)
145147
}
@@ -214,7 +216,13 @@ fun TogiCountryCodePicker(
214216
showCountryCode = showCountryCode,
215217
showFlag = showCountryFlag,
216218
textStyle = textStyle,
217-
backgroundColor = colors.backgroundColor(enabled = true).value,
219+
backgroundColor = colors.backgroundColor(enabled = true).value.let { color ->
220+
if (color == Color.Unspecified || color == Color.Transparent) {
221+
MaterialTheme.colors.surface
222+
} else {
223+
color
224+
}
225+
},
218226
)
219227
},
220228
trailingIcon = {
@@ -251,6 +259,21 @@ fun TogiCountryCodePicker(
251259
)
252260
}
253261

262+
private fun configureInitialCountry(
263+
initialCountryPhoneCode: PhoneCode?,
264+
context: Context,
265+
initialCountryIsoCode: Iso31661alpha2?,
266+
fallbackCountry: CountryData,
267+
): CountryData {
268+
if (initialCountryPhoneCode?.run { !startsWith("+") } == true) {
269+
Log.e(TAG, "initialCountryPhoneCode must start with +")
270+
}
271+
return initialCountryPhoneCode?.let { getCountryFromPhoneCode(it, context) }
272+
?: CountryData.entries.firstOrNull { it.countryIso == initialCountryIsoCode }
273+
?: CountryData.isoMap[getUserIsoCode(context)]
274+
?: fallbackCountry
275+
}
276+
254277
private fun FocusRequester.safeFreeFocus() {
255278
try {
256279
this.freeFocus()

detekt.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,14 +1087,12 @@ HbmartinRuleSet:
10871087
Compose:
10881088
CompositionLocalAllowlist:
10891089
active: true
1090-
# You can optionally define a list of CompositionLocals that are allowed here
1091-
# allowedCompositionLocals: LocalSomething,LocalSomethingElse
10921090
ContentEmitterReturningValues:
10931091
active: true
1094-
# You can optionally add your own composables here
1095-
# contentEmitters: MyComposable,MyOtherComposable
10961092
DefaultsVisibility:
10971093
active: true
1094+
ModifierClickableOrder:
1095+
active: true
10981096
ModifierComposable:
10991097
active: true
11001098
ModifierMissing:
@@ -1106,22 +1104,16 @@ Compose:
11061104
active: true
11071105
ModifierNotUsedAtRoot:
11081106
active: true
1109-
# You can optionally add your own composables here
1110-
# contentEmitters: MyComposable,MyOtherComposable
11111107
ModifierReused:
11121108
active: true
11131109
ModifierWithoutDefault:
11141110
active: true
11151111
MultipleEmitters:
11161112
active: true
1117-
# You can optionally add your own composables here
1118-
# contentEmitters: MyComposable,MyOtherComposable
11191113
MutableParams:
11201114
active: true
11211115
ComposableNaming:
11221116
active: true
1123-
# You can optionally disable the checks in this rule for regex matches against the composable name (e.g. molecule presenters)
1124-
# allowedComposableFunctionNames: .*Presenter,.*MoleculePresenter
11251117
ComposableParamOrder:
11261118
active: true
11271119
PreviewAnnotationNaming:
@@ -1130,16 +1122,14 @@ Compose:
11301122
active: true
11311123
RememberMissing:
11321124
active: true
1125+
RememberContentMissing:
1126+
active: true
11331127
UnstableCollections:
11341128
active: true
11351129
ViewModelForwarding:
11361130
active: true
1137-
# You can optionally use this rule on things other than types ending in "ViewModel" or "Presenter" (which are the defaults). You can add your own via a regex here:
1138-
# allowedStateHolderNames: .*ViewModel,.*Presenter
11391131
ViewModelInjection:
11401132
active: true
1141-
# You can optionally add your own ViewModel factories here
1142-
# viewModelFactories: hiltViewModel,potatoViewModel
11431133

11441134
compose:
11451135
ReusedModifierInstance:

gradle/libs.versions.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin = "1.9.10"
2+
kotlin = "1.9.20"
33
dokka = "1.9.10"
44

55
## SDK Versions
@@ -8,9 +8,9 @@ targetSdk = "34"
88
compileSdk = "34"
99

1010
# Dependencies
11-
android-gradle-plugin = "8.2.0-rc01"
11+
android-gradle-plugin = "8.2.0-rc03"
1212
gradle-versions = "0.49.0"
13-
detekt = "1.23.1"
13+
detekt = "1.23.3"
1414

1515
accompanist = "0.32.0"
1616
androidx-activity-compose = "1.8.0"
@@ -22,15 +22,15 @@ androidx-test-junit = "1.1.5"
2222
compose = "1.5.4"
2323
# https://androidx.dev/storage/compose-compiler/repository/
2424
# https://developer.android.com/jetpack/androidx/releases/compose-compiler
25-
composeCompiler = "1.5.3"
25+
composeCompiler = "1.5.4"
2626

2727
kotlinx-coroutines = "1.7.3"
2828
kotlinx-collections-immutable = "0.3.6"
2929

30-
libphonenumber = "8.13.17"
30+
libphonenumber = "8.13.25"
3131

3232
junit = "4.13.2"
33-
robolectric = "4.10.3"
33+
robolectric = "4.11.1"
3434
paparazzi = "1.3.2-SNAPSHOT"
3535

3636
[libraries]

0 commit comments

Comments
 (0)