Skip to content

Commit

Permalink
ISSUE-389: returned fix for st-Lant screenshots (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
AzamatCherchesov authored Jan 22, 2024
1 parent 1e6f24f commit 02074cd
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ class LanguageImpl(
ConfigurationCompat.getLocales(instrumentation.targetContext.resources.configuration).get(0)

private fun applyCurrentLocaleToContext(locale: Locale) {
// For issue DocLocScreenshotTestCase does not change locale to sr-Latn-RS: https://github.com/KasperskyLab/Kaspresso/issues/389
// added hotfix. For next releases we will find more correct solution.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (locale.country.equals("Latn", true) &&
locale.language.equals("sr", true)
) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val localeManager = instrumentation.targetContext.getSystemService(Context.LOCALE_SERVICE) as LocaleManager
localeManager.applicationLocales = LocaleList.forLanguageTags(Locale.Builder().setLanguage("sr").setScript("Latn").build().toLanguageTag())
} else {
Handler(instrumentation.targetContext.mainLooper).post {
AppCompatDelegate.setApplicationLocales(LocaleListCompat.create(Locale.Builder().setLanguage("sr").setScript("Latn").build()))
}
}
return
}
}

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
val localeManager = instrumentation.targetContext.getSystemService(Context.LOCALE_SERVICE) as LocaleManager
localeManager.applicationLocales = LocaleList.forLanguageTags(locale.toLanguageTag())
Expand Down

0 comments on commit 02074cd

Please sign in to comment.