You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.
Hello, I found a bug using v1.2.4 wih Preference dialog.
After changing language from selecting it from ListPreference dialog activity is recreated but language of the UI stays previous.
As I understand the reason is that in this case method Activity.getResources() is being called before Activity.attachBaseContext().
So LocalizationActivityDelegate.getResources() method change language in Resources object, then in subsequent attachBaseContext() method call next condition is not met: if (!baseLocale.toString().equals(currentLocale.toString(), ignoreCase = true)) {
100% reproducing on Android 10 Pixel 2
v1.2.3 works fine.
To reproduce add next code in sample application: SettingsActivity.java
package com.akexorcist.localizationapp.settingsactivity;
import android.os.Bundle;
import android.preference.PreferenceFragment;
import com.akexorcist.localizationactivity.ui.LocalizationActivity;
import com.akexorcist.localizationapp.R;
public class SettingsActivity extends LocalizationActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_activity);
getFragmentManager().beginTransaction().replace(R.id.main_content, new GeneralPreferenceFragment()).commit();
}
public static class GeneralPreferenceFragment extends PreferenceFragment {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.settings);
setHasOptionsMenu(false);
findPreference("language").setOnPreferenceChangeListener((preference, newValue) -> {
String lang = newValue.toString();
((LocalizationActivity)getActivity()).setLanguage(lang);
return true;
});
}
}
}
Hello, I found a bug using v1.2.4 wih Preference dialog.
After changing language from selecting it from ListPreference dialog activity is recreated but language of the UI stays previous.
As I understand the reason is that in this case method
Activity.getResources()
is being called beforeActivity.attachBaseContext()
.So
LocalizationActivityDelegate.getResources()
method change language in Resources object, then in subsequentattachBaseContext()
method call next condition is not met:if (!baseLocale.toString().equals(currentLocale.toString(), ignoreCase = true)) {
100% reproducing on Android 10 Pixel 2
v1.2.3 works fine.
To reproduce add next code in sample application:
SettingsActivity.java
settings_activity.xml
settings.xml
strings_settings.xml
The text was updated successfully, but these errors were encountered: