mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Compare commits
1 Commits
beta-1.5.1
...
1764-fix-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a94a1708f |
@@ -10,6 +10,7 @@ import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
|
||||
import com.vanniktech.emoji.EmojiManager;
|
||||
import com.vanniktech.emoji.google.GoogleEmojiProvider;
|
||||
@@ -96,6 +97,7 @@ public class BriarApplicationImpl extends Application
|
||||
Localizer.initialize(prefs);
|
||||
super.attachBaseContext(
|
||||
Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
setTheme(base, prefs);
|
||||
ACRA.init(this);
|
||||
}
|
||||
@@ -145,6 +147,7 @@ public class BriarApplicationImpl extends Application
|
||||
@Override
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
Log.d("language", "BriarApplicationImpl#onConfigurationChanged()");
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.Binder;
|
||||
import android.os.IBinder;
|
||||
import android.util.Log;
|
||||
|
||||
import org.briarproject.bramble.api.account.AccountManager;
|
||||
import org.briarproject.bramble.api.crypto.SecretKey;
|
||||
@@ -160,7 +161,9 @@ public class BriarService extends Service {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
Log.d("language", "BriarService#attachBaseContext()");
|
||||
super.attachBaseContext(Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
private void showStartupFailureNotification(StartResult result) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.Resources;
|
||||
import android.util.Log;
|
||||
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
|
||||
@@ -26,22 +27,29 @@ public class Localizer {
|
||||
private Localizer(SharedPreferences sharedPreferences) {
|
||||
this(Locale.getDefault(), getLocaleFromTag(
|
||||
sharedPreferences.getString(LANGUAGE, "default")));
|
||||
Log.d("language", "preference: " +
|
||||
sharedPreferences.getString(LANGUAGE, "default"));
|
||||
}
|
||||
|
||||
private Localizer(Locale systemLocale, @Nullable Locale userLocale) {
|
||||
this.systemLocale = systemLocale;
|
||||
if (userLocale == null) locale = systemLocale;
|
||||
else locale = userLocale;
|
||||
Log.d("language", "Localizer() system locale: " + systemLocale);
|
||||
Log.d("language", "Localizer() current locale: " + locale);
|
||||
}
|
||||
|
||||
// Instantiate the Localizer.
|
||||
public static synchronized void initialize(SharedPreferences prefs) {
|
||||
Log.d("language", "Localizer#initialize()");
|
||||
Log.d("language", "sdk: " + SDK_INT);
|
||||
if (INSTANCE == null)
|
||||
INSTANCE = new Localizer(prefs);
|
||||
}
|
||||
|
||||
// Reinstantiate the Localizer with the system locale
|
||||
public static synchronized void reinitialize() {
|
||||
Log.d("language", "Localizer#reinitialize()");
|
||||
if (INSTANCE != null)
|
||||
INSTANCE = new Localizer(INSTANCE.systemLocale, null);
|
||||
}
|
||||
@@ -72,17 +80,20 @@ public class Localizer {
|
||||
public Context setLocale(Context context) {
|
||||
Resources res = context.getResources();
|
||||
Configuration conf = res.getConfiguration();
|
||||
|
||||
Locale currentLocale;
|
||||
if (SDK_INT >= 24) {
|
||||
currentLocale = conf.getLocales().get(0);
|
||||
} else
|
||||
currentLocale = conf.locale;
|
||||
Log.d("language", "current locale: " + currentLocale);
|
||||
if (locale.equals(currentLocale))
|
||||
return context;
|
||||
Log.d("language", "set locale: " + locale);
|
||||
Locale.setDefault(locale);
|
||||
if (SDK_INT >= 17) {
|
||||
conf.setLocale(locale);
|
||||
context.createConfigurationContext(conf);
|
||||
context = context.createConfigurationContext(conf);
|
||||
} else
|
||||
conf.locale = locale;
|
||||
//noinspection deprecation
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.briar.android.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewGroup.LayoutParams;
|
||||
@@ -36,6 +37,7 @@ import javax.inject.Inject;
|
||||
import androidx.annotation.LayoutRes;
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.appcompat.view.ContextThemeWrapper;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
@@ -106,12 +108,24 @@ public abstract class BaseActivity extends AppCompatActivity
|
||||
for (ActivityLifecycleController alc : lifecycleControllers) {
|
||||
alc.onActivityCreate(this);
|
||||
}
|
||||
|
||||
Log.d("language", "BaseActivity#onCreate()");
|
||||
Context baseContext = getBaseContext();
|
||||
Log.d("language", "Context: " + getBaseContext().toString());
|
||||
if (baseContext instanceof ContextThemeWrapper) {
|
||||
ContextThemeWrapper wrapper = (ContextThemeWrapper) baseContext;
|
||||
Context wrapped = wrapper.getBaseContext();
|
||||
Log.d("language", "Wrapped: " + wrapped.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
Log.d("language", "BaseActivity#attachBaseContext()");
|
||||
Log.d("language", "Context: " + base.toString());
|
||||
super.attachBaseContext(
|
||||
Localizer.getInstance().setLocale(base));
|
||||
Localizer.getInstance().setLocale(this);
|
||||
}
|
||||
|
||||
public ActivityComponent getActivityComponent() {
|
||||
|
||||
Reference in New Issue
Block a user