Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ISSUE-389: returned fix for st-Lant screenshots #622

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading