mirror of
https://github.com/emanuele-f/PCAPdroid.git
synced 2026-06-16 21:10:57 +08:00
Fix bad locale used in Edit Rules
This commit is contained in:
parent
bb55072f45
commit
6b623ea34d
@ -1,7 +1,9 @@
|
||||
package com.emanuelef.remote_capture;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
@ -12,12 +14,14 @@ import java.lang.ref.WeakReference;
|
||||
|
||||
public class PCAPdroid extends Application {
|
||||
private MatchList mVisMask;
|
||||
private Context mLocalizedContext;
|
||||
private static WeakReference<PCAPdroid> mInstance;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mInstance = new WeakReference<>(this);
|
||||
mLocalizedContext = createConfigurationContext(Utils.getLocalizedConfig(this));
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
String theme = prefs.getString(Prefs.PREF_APP_THEME, "");
|
||||
@ -43,4 +47,13 @@ public class PCAPdroid extends Application {
|
||||
|
||||
return mVisMask;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resources getResources() {
|
||||
if(mLocalizedContext == null)
|
||||
return super.getResources();
|
||||
|
||||
// Ensure that the selected locale is used
|
||||
return mLocalizedContext.getResources();
|
||||
}
|
||||
}
|
||||
@ -16,6 +16,7 @@ class BaseActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
// Ensure that the selected locale is used
|
||||
applyOverrideConfiguration(Utils.getLocalizedConfig(base));
|
||||
super.attachBaseContext(base);
|
||||
}
|
||||
|
||||
@ -10,7 +10,6 @@ import android.widget.CheckBox;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.ActionBar;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.emanuelef.remote_capture.PCAPdroid;
|
||||
import com.emanuelef.remote_capture.R;
|
||||
@ -19,7 +18,7 @@ import com.emanuelef.remote_capture.model.FilterDescriptor;
|
||||
import com.emanuelef.remote_capture.model.MatchList;
|
||||
import com.google.android.material.chip.Chip;
|
||||
|
||||
public class EditFilterActivity extends AppCompatActivity {
|
||||
public class EditFilterActivity extends BaseActivity {
|
||||
public static final String FILTER_DESCRIPTOR = "filter";
|
||||
private static final String TAG = "FilterEditActivity";
|
||||
private FilterDescriptor mFilter;
|
||||
|
||||
@ -194,6 +194,7 @@ public class SettingsActivity extends BaseActivity {
|
||||
if(SettingsActivity.ACTION_LANG_RESTART.equals(getActivity().getIntent().getAction()))
|
||||
scrollToPreference(appLang);
|
||||
|
||||
// Current locale applied via BaseActivity.attachBaseContext
|
||||
appLang.setOnPreferenceChangeListener((preference, newValue) -> {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ import java.util.List;
|
||||
|
||||
/* Matches connections against the configured rules. */
|
||||
public class MatchList {
|
||||
private static final String TAG = "ConnectionsMatcher";
|
||||
private static final String TAG = "MatchList";
|
||||
private static final StyleSpan italic = new StyleSpan(Typeface.ITALIC);
|
||||
private final Context mContext;
|
||||
private final SharedPreferences mPrefs;
|
||||
@ -106,6 +106,7 @@ public class MatchList {
|
||||
|
||||
public void reload() {
|
||||
String serialized = mPrefs.getString(mPrefName, "");
|
||||
//Log.d(TAG, serialized);
|
||||
|
||||
if(!serialized.isEmpty())
|
||||
fromJson(serialized);
|
||||
@ -115,7 +116,7 @@ public class MatchList {
|
||||
|
||||
public void save() {
|
||||
mPrefs.edit()
|
||||
.putString(Prefs.PREF_VISUALIZATION_MASK, toJson())
|
||||
.putString(mPrefName, toJson())
|
||||
.apply();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user