mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-23 08:09:54 +01:00
fix review
This commit is contained in:
@@ -295,7 +295,7 @@ task verifyTranslations {
|
|||||||
|
|
||||||
def folders = ["default", "en-US"]
|
def folders = ["default", "en-US"]
|
||||||
new File("briar-android/src/main/res").eachDir { dir ->
|
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", "-"))
|
folders.add(dir.name.substring(7).replace("-r", "-"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package org.briarproject.briar.android;
|
|||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.os.StrictMode;
|
import android.os.StrictMode;
|
||||||
import android.os.StrictMode.ThreadPolicy;
|
import android.os.StrictMode.ThreadPolicy;
|
||||||
import android.os.StrictMode.VmPolicy;
|
import android.os.StrictMode.VmPolicy;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.acra.ACRA;
|
import org.acra.ACRA;
|
||||||
import org.acra.ReportingInteractionMode;
|
import org.acra.ReportingInteractionMode;
|
||||||
@@ -76,8 +78,10 @@ public class BriarApplicationImpl extends Application
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void attachBaseContext(Context base) {
|
protected void attachBaseContext(Context base) {
|
||||||
|
SharedPreferences prefs =
|
||||||
|
PreferenceManager.getDefaultSharedPreferences(base);
|
||||||
// Loading the language needs to be done here.
|
// Loading the language needs to be done here.
|
||||||
Localizer.initialize(base);
|
Localizer.initialize(prefs);
|
||||||
super.attachBaseContext(
|
super.attachBaseContext(
|
||||||
Localizer.getInstance().setLocale(base));
|
Localizer.getInstance().setLocale(base));
|
||||||
ACRA.init(this);
|
ACRA.init(this);
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ import android.content.Context;
|
|||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
|
|
||||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
||||||
|
|
||||||
import static android.os.Build.VERSION.SDK_INT;
|
import static android.os.Build.VERSION.SDK_INT;
|
||||||
import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
|
import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
|
||||||
@@ -19,20 +17,22 @@ import static org.briarproject.briar.android.settings.SettingsFragment.LANGUAGE;
|
|||||||
@NotNullByDefault
|
@NotNullByDefault
|
||||||
public class Localizer {
|
public class Localizer {
|
||||||
|
|
||||||
|
// Locking: class
|
||||||
|
@Nullable
|
||||||
private static Localizer INSTANCE;
|
private static Localizer INSTANCE;
|
||||||
@Nullable
|
@Nullable
|
||||||
private final Locale locale;
|
private final Locale locale;
|
||||||
private final SharedPreferences sharedPreferences;
|
private final SharedPreferences sharedPreferences;
|
||||||
|
|
||||||
private Localizer(Context context) {
|
private Localizer(SharedPreferences prefs) {
|
||||||
sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
|
this.sharedPreferences = prefs;
|
||||||
locale = getLocaleFromTag(
|
locale = getLocaleFromTag(
|
||||||
sharedPreferences.getString(LANGUAGE, "default"));
|
sharedPreferences.getString(LANGUAGE, "default"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void initialize(Context context) {
|
public static synchronized void initialize(SharedPreferences prefs) {
|
||||||
if (INSTANCE == null)
|
if (INSTANCE == null)
|
||||||
INSTANCE = new Localizer(context);
|
INSTANCE = new Localizer(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized Localizer getInstance() {
|
public static synchronized Localizer getInstance() {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package org.briarproject.briar.android;
|
package org.briarproject.briar.android;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
import org.briarproject.bramble.BrambleCoreModule;
|
import org.briarproject.bramble.BrambleCoreModule;
|
||||||
import org.briarproject.briar.BriarCoreModule;
|
import org.briarproject.briar.BriarCoreModule;
|
||||||
@@ -27,7 +29,8 @@ public class TestBriarApplication extends Application
|
|||||||
super.onCreate();
|
super.onCreate();
|
||||||
LOG.info("Created");
|
LOG.info("Created");
|
||||||
|
|
||||||
Localizer.initialize(this);
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||||
|
Localizer.initialize(prefs);
|
||||||
applicationComponent = DaggerAndroidComponent.builder()
|
applicationComponent = DaggerAndroidComponent.builder()
|
||||||
.appModule(new AppModule(this))
|
.appModule(new AppModule(this))
|
||||||
.build();
|
.build();
|
||||||
|
|||||||
Reference in New Issue
Block a user