mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 21:59:54 +01:00
Merge branch 'language_improvements' into 'master'
Language improvements See merge request akwizgran/briar!829
This commit is contained in:
@@ -20,19 +20,33 @@ public class Localizer {
|
|||||||
// Locking: class
|
// Locking: class
|
||||||
@Nullable
|
@Nullable
|
||||||
private static Localizer INSTANCE;
|
private static Localizer INSTANCE;
|
||||||
@Nullable
|
private final Locale systemLocale;
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
|
|
||||||
private Localizer(SharedPreferences sharedPreferences) {
|
private Localizer(SharedPreferences sharedPreferences) {
|
||||||
locale = getLocaleFromTag(
|
this(Locale.getDefault(), getLocaleFromTag(
|
||||||
sharedPreferences.getString(LANGUAGE, "default"));
|
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) {
|
public static synchronized void initialize(SharedPreferences prefs) {
|
||||||
if (INSTANCE == null)
|
if (INSTANCE == null)
|
||||||
INSTANCE = new Localizer(prefs);
|
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() {
|
public static synchronized Localizer getInstance() {
|
||||||
if (INSTANCE == null)
|
if (INSTANCE == null)
|
||||||
throw new IllegalStateException("Localizer not initialized");
|
throw new IllegalStateException("Localizer not initialized");
|
||||||
@@ -54,9 +68,8 @@ public class Localizer {
|
|||||||
return new Locale(tag);
|
return new Locale(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Returns the localized version of context
|
||||||
public Context setLocale(Context context) {
|
public Context setLocale(Context context) {
|
||||||
if (locale == null)
|
|
||||||
return context;
|
|
||||||
Resources res = context.getResources();
|
Resources res = context.getResources();
|
||||||
Configuration conf = res.getConfiguration();
|
Configuration conf = res.getConfiguration();
|
||||||
Locale currentLocale;
|
Locale currentLocale;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import android.widget.EditText;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
|
|
||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
|
import org.briarproject.briar.android.Localizer;
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
import org.briarproject.briar.android.activity.BaseActivity;
|
import org.briarproject.briar.android.activity.BaseActivity;
|
||||||
import org.briarproject.briar.android.controller.BriarController;
|
import org.briarproject.briar.android.controller.BriarController;
|
||||||
@@ -105,6 +106,7 @@ public class PasswordActivity extends BaseActivity {
|
|||||||
|
|
||||||
private void deleteAccount() {
|
private void deleteAccount() {
|
||||||
passwordController.deleteAccount(this);
|
passwordController.deleteAccount(this);
|
||||||
|
Localizer.reinitialize();
|
||||||
setResult(RESULT_CANCELED);
|
setResult(RESULT_CANCELED);
|
||||||
Intent i = new Intent(this, SetupActivity.class);
|
Intent i = new Intent(this, SetupActivity.class);
|
||||||
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
|
i.setFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|||||||
Reference in New Issue
Block a user