mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Force locale on account deletion
This commit is contained in:
@@ -25,7 +25,7 @@ class BriarAccountManager extends AndroidAccountManager {
|
|||||||
public void deleteAccount() {
|
public void deleteAccount() {
|
||||||
synchronized (stateChangeLock) {
|
synchronized (stateChangeLock) {
|
||||||
super.deleteAccount();
|
super.deleteAccount();
|
||||||
Localizer.reinitialize();
|
Localizer.reinitialize(appContext);
|
||||||
UiUtils.setTheme(appContext,
|
UiUtils.setTheme(appContext,
|
||||||
appContext.getString(R.string.pref_theme_light_value));
|
appContext.getString(R.string.pref_theme_light_value));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,11 @@ public class Localizer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Reinstantiate the Localizer with the system locale
|
// Reinstantiate the Localizer with the system locale
|
||||||
public static synchronized void reinitialize() {
|
public static synchronized void reinitialize(Context appContext) {
|
||||||
if (INSTANCE != null)
|
if (INSTANCE != null) {
|
||||||
INSTANCE = new Localizer(INSTANCE.systemLocale, null);
|
INSTANCE = new Localizer(INSTANCE.systemLocale, null);
|
||||||
|
INSTANCE.forceLocale(appContext);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the current instance.
|
// Get the current instance.
|
||||||
@@ -84,6 +86,18 @@ public class Localizer {
|
|||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Forces the update of the resources through the deprecated API.
|
||||||
|
// Necessary on API >= 17 to update the foreground notification if the
|
||||||
|
// account was deleted.
|
||||||
|
public void forceLocale(Context context) {
|
||||||
|
Resources res = context.getResources();
|
||||||
|
Configuration conf = res.getConfiguration();
|
||||||
|
updateConfiguration(conf, locale);
|
||||||
|
//noinspection deprecation
|
||||||
|
// Use the old API on < 17
|
||||||
|
res.updateConfiguration(conf, res.getDisplayMetrics());
|
||||||
|
}
|
||||||
|
|
||||||
private void updateConfiguration(Configuration conf, Locale locale) {
|
private void updateConfiguration(Configuration conf, Locale locale) {
|
||||||
if (SDK_INT >= 17) {
|
if (SDK_INT >= 17) {
|
||||||
conf.setLocale(locale);
|
conf.setLocale(locale);
|
||||||
|
|||||||
Reference in New Issue
Block a user