diff --git a/app/src/main/java/info/nightscout/androidaps/MainActivity.java b/app/src/main/java/info/nightscout/androidaps/MainActivity.java index 0d65cbb834..f6a250dc4a 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/MainActivity.java @@ -92,7 +92,6 @@ public class MainActivity extends NoSplashAppCompatActivity { @Override public void onCreate(Bundle savedInstanceState) { - AndroidInjection.inject(this); super.onCreate(savedInstanceState); Iconify.with(new FontAwesomeModule()); diff --git a/app/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt index b4ac7eff51..aaf85c6adf 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/NoSplashAppCompatActivity.kt @@ -10,8 +10,8 @@ import info.nightscout.androidaps.utils.LocaleHelper open class NoSplashAppCompatActivity : DaggerAppCompatActivity() { public override fun onCreate(savedInstanceState: Bundle?) { - setTheme(R.style.AppTheme_NoActionBar) super.onCreate(savedInstanceState) + setTheme(R.style.AppTheme_NoActionBar) } public override fun attachBaseContext(newBase: Context) { diff --git a/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt b/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt index 447d076d93..62da88a15d 100644 --- a/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt +++ b/app/src/main/java/info/nightscout/androidaps/utils/LocaleHelper.kt @@ -4,16 +4,19 @@ import android.content.Context import android.content.ContextWrapper import android.os.Build import android.os.LocaleList +import androidx.preference.PreferenceManager import info.nightscout.androidaps.R import java.util.* - object LocaleHelper { - fun currentLanguage(): String = - SP.getString(R.string.key_language, Locale.getDefault().language) + private fun currentLanguage(context: Context): String = + PreferenceManager.getDefaultSharedPreferences(context).getString(context.getString(R.string.key_language), "en") + ?: "en" + // injection not possible because of use in attachBaseContext + //SP.getString(R.string.key_language, Locale.getDefault().language) - private fun currentLocale(): Locale { - val language = currentLanguage() + private fun currentLocale(context: Context): Locale { + val language = currentLanguage(context) var locale = Locale(language) if (language.contains("_")) { // language with country like pt_BR defined in arrays.xml @@ -26,7 +29,7 @@ object LocaleHelper { @Suppress("DEPRECATION") fun update(context: Context) { - val locale = currentLocale() + val locale = currentLocale(context) Locale.setDefault(locale) val resources = context.resources val configuration = resources.configuration @@ -39,7 +42,7 @@ object LocaleHelper { fun wrap(ctx: Context): ContextWrapper { val res = ctx.resources val configuration = res.configuration - val newLocale = currentLocale() + val newLocale = currentLocale(ctx) val context = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { configuration.setLocale(newLocale) val localeList = LocaleList(newLocale)