fixed prefs

This commit is contained in:
Adithya Abraham Philip 2015-06-07 21:40:27 +05:30
parent f8f4876b78
commit 76aa34300c
2 changed files with 13 additions and 1 deletions

View File

@ -279,6 +279,9 @@ public class SettingsActivity extends PreferenceActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// makes android's preference framework write to our file instead of default
// This allows us to use the "persistent" attribute to simplify code
sPreferences.setPreferenceManagerFileAndMode(getPreferenceManager());
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.proxy_prefs);

View File

@ -22,6 +22,7 @@ import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import info.guardianproject.onionkit.ui.OrbotHelper;
import org.sufficientlysecure.keychain.Constants;
import org.sufficientlysecure.keychain.Constants.Pref;
@ -42,6 +43,9 @@ public class Preferences {
private SharedPreferences mSharedPreferences;
private Resources mResources;
private static String PREF_FILE_NAME = "APG.main";
private static int PREF_FILE_MODE = Context.MODE_MULTI_PROCESS;
public static synchronized Preferences getPreferences(Context context) {
return getPreferences(context, false);
}
@ -61,9 +65,14 @@ public class Preferences {
updateSharedPreferences(context);
}
public void setPreferenceManagerFileAndMode(PreferenceManager manager) {
manager.setSharedPreferencesName(PREF_FILE_NAME);
manager.setSharedPreferencesMode(PREF_FILE_MODE);
}
public void updateSharedPreferences(Context context) {
// multi-process safe preferences
mSharedPreferences = context.getSharedPreferences("APG.main", Context.MODE_MULTI_PROCESS);
mSharedPreferences = context.getSharedPreferences(PREF_FILE_NAME, PREF_FILE_MODE);
}
public String getLanguage() {