Skip to content
Snippets Groups Projects
Verified Commit 695b543b authored by Julian Dehm's avatar Julian Dehm
Browse files

fix review

parent 75e910e1
No related branches found
No related tags found
No related merge requests found
......@@ -295,7 +295,7 @@ task verifyTranslations {
def folders = ["default", "en-US"]
new File("briar-android/src/main/res").eachDir { dir ->
if (dir.name.startsWith("values-")) {
if (dir.name.startsWith("values-") && !dir.name.endsWith("night")) {
folders.add(dir.name.substring(7).replace("-r", "-"))
}
}
......
......@@ -2,10 +2,12 @@ package org.briarproject.briar.android;
import android.app.Application;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.os.StrictMode;
import android.os.StrictMode.ThreadPolicy;
import android.os.StrictMode.VmPolicy;
import android.preference.PreferenceManager;
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
......@@ -76,8 +78,10 @@ public class BriarApplicationImpl extends Application
@Override
protected void attachBaseContext(Context base) {
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(base);
// Loading the language needs to be done here.
Localizer.initialize(base);
Localizer.initialize(prefs);
super.attachBaseContext(
Localizer.getInstance().setLocale(base));
ACRA.init(this);
......
......@@ -4,14 +4,12 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
import java.util.Locale;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import static android.os.Build.VERSION.SDK_INT;
import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
......@@ -19,20 +17,22 @@ import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
@NotNullByDefault
public class Localizer {
// Locking: class
@Nullable
private static Localizer INSTANCE;
@Nullable
private final Locale locale;
private final SharedPreferences sharedPreferences;
private Localizer(Context context) {
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
private Localizer(SharedPreferences prefs) {
this.sharedPreferences = prefs;
locale = getLocaleFromTag(
sharedPreferences.getString(LANGUAGE, "default"));
}
public static synchronized void initialize(Context context) {
public static synchronized void initialize(SharedPreferences prefs) {
if (INSTANCE == null)
INSTANCE = new Localizer(context);
INSTANCE = new Localizer(prefs);
}
public static synchronized Localizer getInstance() {
......
package org.briarproject.briar.android;
import android.app.Application;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import org.briarproject.bramble.BrambleCoreModule;
import org.briarproject.briar.BriarCoreModule;
......@@ -27,7 +29,8 @@ public class TestBriarApplication extends Application
super.onCreate();
LOG.info("Created");
Localizer.initialize(this);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
Localizer.initialize(prefs);
applicationComponent = DaggerAndroidComponent.builder()
.appModule(new AppModule(this))
.build();
......
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