Skip to content

Commit

Permalink
Fix the issue that the app cannot be automatically launched on kitkat
Browse files Browse the repository at this point in the history
  • Loading branch information
vrichv committed Aug 12, 2024
1 parent 023b624 commit c134af8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/src/main/java/com/lizongying/mytv0/LocaleContextWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import android.os.Build
import android.os.LocaleList
import java.util.Locale

class LocaleContextWrapper(base: Context) : ContextWrapper(base) {
class LocaleContextWrapper private constructor(base: Context) : ContextWrapper(base) {
companion object {
fun wrap(context: Context, newLocale: Locale): ContextWrapper {
fun wrap(context: Context, newLocale: Locale): Context {
val resources = context.resources
val configuration = resources.configuration

Expand All @@ -28,7 +28,12 @@ class LocaleContextWrapper(base: Context) : ContextWrapper(base) {
context
}

return LocaleContextWrapper(updatedContext)
// For KitKat and below, return the original context
return if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
updatedContext
} else {
LocaleContextWrapper(updatedContext)
}
}
}
}

0 comments on commit c134af8

Please sign in to comment.