Skip to content

Commit f32d6cc

Browse files
authored
Merge pull request #758 from qonversion/release-nocodes/1.3.0
2 parents c66bd6d + 846b06e commit f32d6cc

13 files changed

Lines changed: 96 additions & 116 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ buildscript {
1010
versionCode: 1
1111
]
1212
nocodes = [
13-
versionName: "1.2.2",
13+
versionName: "1.3.0",
1414
versionCode: 1
1515
]
1616
}

config/detekt/baseline.xml

Lines changed: 0 additions & 107 deletions
Large diffs are not rendered by default.

config/detekt/detekt.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ complexity:
112112
threshold: 60
113113
ignoreAnnotated: []
114114
LongParameterList:
115-
active: true
115+
active: false
116116
functionThreshold: 6
117117
constructorThreshold: 7
118118
ignoreDefaultParameters: false
@@ -306,7 +306,7 @@ formatting:
306306
indentSize: 4
307307
continuationIndentSize: 4
308308
MaximumLineLength:
309-
active: true
309+
active: false
310310
maxLineLength: 120
311311
ignoreBackTickedIdentifier: false
312312
ModifierOrdering:
@@ -678,7 +678,7 @@ style:
678678
MandatoryBracesLoops:
679679
active: false
680680
MaxLineLength:
681-
active: true
681+
active: false
682682
maxLineLength: 120
683683
excludePackageStatements: true
684684
excludeImportStatements: true

fastlane/report.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66

77

8-
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000197">
8+
<testcase classname="fastlane.lanes" name="0: default_platform" time="0.000233">
99

1010
</testcase>
1111

nocodes/src/main/java/io/qonversion/nocodes/NoCodes.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,19 @@ interface NoCodes {
130130
* @param logTag the desired log tag.
131131
*/
132132
fun setLogTag(logTag: String)
133+
134+
/**
135+
* Set a custom locale for No-Code screens localization.
136+
* If set, this locale will take priority over the system default locale when determining
137+
* which localization to show on No-Code screens.
138+
* The locale should be in standard format (e.g., "en", "en-US", "de", "de-DE").
139+
*
140+
* You may set locale both *after* Qonversion No-Codes SDK initializing with [NoCodes.setLocale]
141+
* and *while* Qonversion No-Codes initializing via [NoCodesConfig.Builder.setLocale]
142+
*
143+
* Pass null to reset to system default locale.
144+
*
145+
* @param locale the custom locale code, or null to use system default.
146+
*/
147+
fun setLocale(locale: String?)
133148
}

nocodes/src/main/java/io/qonversion/nocodes/NoCodesConfig.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ class NoCodesConfig internal constructor(
3131
internal val screenCustomizationDelegate: ScreenCustomizationDelegate?,
3232
internal val purchaseDelegate: PurchaseDelegate?,
3333
internal val purchaseDelegateWithCallbacks: PurchaseDelegateWithCallbacks?,
34+
internal val locale: String?,
3435
) {
3536

3637
/**
@@ -55,6 +56,7 @@ class NoCodesConfig internal constructor(
5556
private var logLevel = LogLevel.Info
5657
private var logTag = DEFAULT_LOG_TAG
5758
private var customFallbackFileName: String? = null
59+
private var locale: String? = null
5860

5961
/**
6062
* Provide a delegate to be notified about the no-code screens events.
@@ -157,6 +159,18 @@ class NoCodesConfig internal constructor(
157159
this.customFallbackFileName = fileName
158160
}
159161

162+
/**
163+
* Set a custom locale for No-Code screens localization.
164+
* If set, this locale will take priority over the system default locale.
165+
* The locale should be in standard format (e.g., "en", "en-US", "de", "de-DE").
166+
*
167+
* @param locale the custom locale code.
168+
* @return builder instance for chain calls.
169+
*/
170+
fun setLocale(locale: String): Builder = apply {
171+
this.locale = locale
172+
}
173+
160174
/**
161175
* Generate [NoCodesConfig] instance with all the provided configurations.
162176
* This method also validates some of the provided data.
@@ -182,6 +196,7 @@ class NoCodesConfig internal constructor(
182196
screenCustomizationDelegate,
183197
purchaseDelegate,
184198
purchaseDelegateWithCallbacks,
199+
locale,
185200
)
186201
}
187202
}

nocodes/src/main/java/io/qonversion/nocodes/internal/NoCodesInternal.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,8 @@ internal class NoCodesInternal(
6969
override fun setLogTag(logTag: String) {
7070
internalConfig.loggerConfig = internalConfig.loggerConfig.copy(logTag = logTag)
7171
}
72+
73+
override fun setLocale(locale: String?) {
74+
internalConfig.customLocale = locale
75+
}
7276
}

nocodes/src/main/java/io/qonversion/nocodes/internal/di/controllers/ControllersAssemblyImpl.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ internal class ControllersAssemblyImpl(
3535
miscAssembly.noCodesDelegateProvider(),
3636
miscAssembly.jsonSerializer(),
3737
mappersAssembly.actionMapper(),
38+
{ miscAssembly.customLocale() }
3839
)
3940
}
4041
}

nocodes/src/main/java/io/qonversion/nocodes/internal/di/misc/MiscAssembly.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ internal interface MiscAssembly {
1414

1515
fun locale(): Locale
1616

17+
/**
18+
* Returns the custom locale string set by the client, or null if using system default.
19+
*/
20+
fun customLocale(): String?
21+
1722
fun jsonSerializer(): Serializer
1823

1924
fun exponentialDelayCalculator(): RetryDelayCalculator

nocodes/src/main/java/io/qonversion/nocodes/internal/di/misc/MiscAssemblyImpl.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ internal class MiscAssemblyImpl(
2525

2626
override fun logger(): Logger = ConsoleLogger(internalConfig)
2727

28-
override fun locale(): Locale = Locale.getDefault()
28+
override fun locale(): Locale {
29+
return internalConfig.customLocale?.let { customLocale ->
30+
// Parse custom locale string (e.g., "en", "en-US", "ru-RU")
31+
val parts = customLocale.replace("_", "-").split("-")
32+
when (parts.size) {
33+
1 -> Locale(parts[0])
34+
2 -> Locale(parts[0], parts[1])
35+
else -> Locale(parts[0], parts[1], parts.drop(2).joinToString("-"))
36+
}
37+
} ?: Locale.getDefault()
38+
}
39+
40+
override fun customLocale(): String? = internalConfig.customLocale
2941

3042
override fun jsonSerializer(): Serializer = JsonSerializer()
3143

0 commit comments

Comments
 (0)