Skip to content
Snippets Groups Projects
Commit dcacae07 authored by Administrator's avatar Administrator
Browse files

Merge branch 'language_improvements' into 'master'

Language improvements

See merge request akwizgran/briar!829
parents aefc5c51 7a2df3d6
No related branches found
No related tags found
No related merge requests found
......@@ -20,19 +20,33 @@ public class Localizer {
// Locking: class
@Nullable
private static Localizer INSTANCE;
@Nullable
private final Locale systemLocale;
private final Locale locale;
private Localizer(SharedPreferences sharedPreferences) {
locale = getLocaleFromTag(
sharedPreferences.getString(LANGUAGE, "default"));
this(Locale.getDefault(), getLocaleFromTag(
sharedPreferences.getString(LANGUAGE, "default")));
}
private Localizer(Locale systemLocale, @Nullable Locale userLocale) {
this.systemLocale = systemLocale;
if (userLocale == null) locale = systemLocale;
else locale = userLocale;
}
// Instantiate the Localizer.
public static synchronized void initialize(SharedPreferences prefs) {
if (INSTANCE == null)
INSTANCE = new Localizer(prefs);
}
// Reinstantiate the Localizer with the system locale
public static synchronized void reinitialize() {
if (INSTANCE != null)
INSTANCE = new Localizer(INSTANCE.systemLocale, null);
}
// Get the current instance.
public static synchronized Localizer getInstance() {
if (INSTANCE == null)
throw new IllegalStateException("Localizer not initialized");
......@@ -54,9 +68,8 @@ public class Localizer {
return new Locale(tag);
}
// Returns the localized version of context
public Context setLocale(Context context) {
if (locale == null)
return context;
Resources res = context.getResources();
Configuration conf = res.getConfiguration();
Locale currentLocale;
......
......@@ -13,6 +13,7 @@ import android.widget.EditText;
import android.widget.ProgressBar;
import org.briarproject.briar.R;
import org.briarproject.briar.android.Localizer;
import org.briarproject.briar.android.activity.ActivityComponent;
import org.briarproject.briar.android.activity.BaseActivity;
import org.briarproject.briar.android.controller.BriarController;
......@@ -105,6 +106,7 @@ public class PasswordActivity extends BaseActivity {
private void deleteAccount() {
passwordController.deleteAccount(this);
Localizer.reinitialize();
setResult(RESULT_CANCELED);
Intent i = new Intent(this, SetupActivity.class);
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment