File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
core/src/main/java/io/snabble/sdk Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change 11# Changelog
22All notable changes to this project will be documented in this file.
33
4+ ## [ 0.68.4]
5+
6+ - Fixed a rare formatting bug in AcceptedLanguageInterceptor
7+
48## [ 0.68.3]
59
610- Fixed a regression when pre-weighed products to the shopping cart
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ allprojects {
3333 }
3434
3535 project. ext {
36- sdkVersion= ' 0.68.3 '
36+ sdkVersion= ' 0.68.4 '
3737 versionCode= 1
3838
3939 compileSdkVersion= 31
Original file line number Diff line number Diff line change @@ -6,23 +6,23 @@ import androidx.annotation.RestrictTo
66import okhttp3.Interceptor
77import okhttp3.Request
88import okhttp3.Response
9+ import java.text.DecimalFormat
10+ import java.text.DecimalFormatSymbols
911import java.util.*
1012
1113@RestrictTo(RestrictTo .Scope .LIBRARY )
1214internal class AcceptedLanguageInterceptor : Interceptor {
15+ private val formatter = DecimalFormat (" #.##" , DecimalFormatSymbols (Locale .US ))
16+
1317 private val acceptedLanguagesHeader: String
1418 get() = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .N ) {
1519 val list = LocaleList .getDefault()
1620 val all = (0 until list.size()).map { i -> list.get(i) }
1721 val simplified = (all.map { it.toLanguageTag() } + all.map { it.language }).distinct()
1822 var str = simplified.first()
1923 for (i in 1 until simplified.size) {
20- str + = " ,${simplified[i]} ;q=${
21- " %.1f" .format(
22- Locale .US ,
23- 1 - (1 / simplified.size.toFloat()) * i
24- )
25- } "
24+ val weight = formatter.format(1 - (1 / simplified.size.toFloat()) * i)
25+ str + = " ,${simplified[i]} ;q=$weight "
2626 }
2727 str
2828 } else Locale .getDefault().language
You can’t perform that action at this time.
0 commit comments