Skip to content

Commit

Permalink
For mozilla-mobile/fenix#9413 - Workaround Android 8 to update layout…
Browse files Browse the repository at this point in the history
…Direction on activity recreation
  • Loading branch information
boek committed Apr 16, 2020
1 parent e796fa7 commit 3281e2e
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -5,6 +5,8 @@
package mozilla.components.support.locale

import android.content.Context
import android.os.Build
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

/**
Expand All @@ -15,4 +17,15 @@ open class LocaleAwareAppCompatActivity : AppCompatActivity() {
val context = LocaleManager.updateResources(base)
super.attachBaseContext(context)
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

// Android 8 has a bug which doesn't change the layoutDirection on activity recreation.
// https://github.com/mozilla-mobile/fenix/issues/9413
// https://stackoverflow.com/questions/46296202/rtl-layout-bug-in-android-oreo#comment98890942_46298101
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.O) {
window.decorView.layoutDirection = resources.configuration.layoutDirection
}
}
}

0 comments on commit 3281e2e

Please sign in to comment.